diff --git a/Graphs/gFlagsLine.cpp b/Graphs/gFlagsLine.cpp
index 787656ed..f88a0012 100644
--- a/Graphs/gFlagsLine.cpp
+++ b/Graphs/gFlagsLine.cpp
@@ -14,8 +14,8 @@ gFlagsGroup::gFlagsGroup()
 {
     //static QColor col=Qt::black;
 
-    addGLBuf(quads=new GLShortBuffer(512,GL_QUADS));
-    addGLBuf(lines=new GLShortBuffer(20,GL_LINE_LOOP));
+    addVertexBuffer(quads=new gVertexBuffer(512,GL_QUADS));
+    addVertexBuffer(lines=new gVertexBuffer(20,GL_LINE_LOOP));
     quads->setAntiAlias(true);
     lines->setAntiAlias(false);
     m_barh=0;
@@ -75,17 +75,19 @@ void gFlagsGroup::paint(gGraph &w, int left, int top, int width, int height)
     for (int i=0;i<lvisible.size();i++) {
         // Alternating box color
         if (i & 1) barcol=&col1; else barcol=&col2;
-        quads->add(left, linetop, left, linetop+m_barh,   left+width-1, linetop+m_barh, left+width-1, linetop, *barcol);
+        quads->add(left, linetop, left, linetop+m_barh,   left+width-1, linetop+m_barh, left+width-1, linetop, barcol->rgba());
 
         // Paint the actual flags
         lvisible[i]->paint(w,left,linetop,width,m_barh);
         linetop+=m_barh;
     }
 
-    GLShortBuffer *outlines=w.lines();
+    gVertexBuffer *outlines=w.lines();
     QColor blk=Qt::black;
-    outlines->add(left-1, top, left-1, top+height, left-1, top+height, left+width,top+height, blk);
-    outlines->add(left+width,top+height, left+width, top, left+width, top, left-1, top, blk);
+    outlines->add(left-1, top, left-1, top+height, blk.rgba());
+    outlines->add(left-1, top+height, left+width,top+height, blk.rgba());
+    outlines->add(left+width,top+height, left+width, top,blk.rgba());
+    outlines->add(left+width, top, left-1, top, blk.rgba());
 
     //lines->add(left-1, top, left-1, top+height);
     //lines->add(left+width, top+height, left+width, top);
@@ -94,7 +96,7 @@ void gFlagsGroup::paint(gGraph &w, int left, int top, int width, int height)
 gFlagsLine::gFlagsLine(ChannelID code,QColor flag_color,QString label,bool always_visible,FlagType flt)
 :Layer(code),m_label(label),m_always_visible(always_visible),m_flt(flt),m_flag_color(flag_color)
 {
-    addGLBuf(quads=new GLShortBuffer(2048,GL_QUADS));
+    addVertexBuffer(quads=new gVertexBuffer(2048,GL_QUADS));
     //addGLBuf(lines=new GLBuffer(flag_color,1024,GL_LINES));
     quads->setAntiAlias(true);
     //lines->setAntiAlias(true);
@@ -138,7 +140,7 @@ void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height)
     float bottom=top+height-2;
     bool verts_exceeded=false;
     qint64 X,X2,L;
-    m_flag_color=schema::channel[m_code].defaultColor();
+    lines->setColor(schema::channel[m_code].defaultColor().rgba());
     for (QVector<Session *>::iterator s=m_day->begin();s!=m_day->end(); s++) {
         if (!(*s)->enabled()) continue;
 
@@ -154,7 +156,7 @@ void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height)
             if (X > maxx) break;
             x1=(X - minx) * xmult + left;
             if (m_flt==FT_Bar) {
-                lines->add(x1,bartop,x1,bottom,m_flag_color);
+                lines->add(x1,bartop,x1,bottom);
                 if (lines->full()) { verts_exceeded=true; break; }
             } else if (m_flt==FT_Span) {
                 x2=(X2-minx)*xmult+left;
@@ -163,7 +165,7 @@ void gFlagsLine::paint(gGraph & w,int left, int top, int width, int height)
                     x1-=1;
                     x2+=1;
                 }*/
-                quads->add(x2,bartop,x1,bartop, x1,bottom,x2,bottom,m_flag_color);
+                quads->add(x2,bartop,x1,bartop, x1,bottom,x2,bottom,m_flag_color.rgba());
                 if (quads->full()) { verts_exceeded=true; break; }
             }
         }
diff --git a/Graphs/gFlagsLine.h b/Graphs/gFlagsLine.h
index 740a698d..df635b0f 100644
--- a/Graphs/gFlagsLine.h
+++ b/Graphs/gFlagsLine.h
@@ -50,7 +50,8 @@ class gFlagsLine:public Layer
         int total_lines,line_num;
         FlagType m_flt;
         QColor m_flag_color;
-        GLShortBuffer *quads, *lines;
+        gVertexBuffer *quads;
+        gVertexBuffer *lines;
         int m_lx, m_ly;
 };
 
@@ -87,7 +88,7 @@ public:
     QVector<gFlagsLine *> & visibleLayers() { return lvisible; }
 
 protected:
-    GLShortBuffer *quads, *lines;
+    gVertexBuffer *quads, *lines;
     QVector<gFlagsLine *> lvisible;
     float m_barh;
     bool m_empty;
diff --git a/Graphs/gFooBar.cpp b/Graphs/gFooBar.cpp
index 91d85fbf..498763cd 100644
--- a/Graphs/gFooBar.cpp
+++ b/Graphs/gFooBar.cpp
@@ -9,8 +9,8 @@
 gShadowArea::gShadowArea(QColor shadow_color,QColor line_color)
 :Layer(NoChannel),m_shadow_color(shadow_color),m_line_color(line_color)
 {
-    addGLBuf(quads=new GLShortBuffer(20,GL_QUADS));
-    addGLBuf(lines=new GLShortBuffer(20,GL_LINES));
+    addVertexBuffer(quads=new gVertexBuffer(20,GL_QUADS));
+    addVertexBuffer(lines=new gVertexBuffer(20,GL_LINES));
     quads->forceAntiAlias(true);
     lines->setAntiAlias(true);
     lines->setSize(2);
@@ -35,11 +35,11 @@ void gShadowArea::paint(gGraph & w,int left, int top, int width, int height)
     double px=((1/rmx)*(w.min_x-w.rmin_x))*width;
     double py=((1/rmx)*(w.max_x-w.rmin_x))*width;
 
-    quads->add(start_px,top,start_px,top+height,start_px+px, top+height, start_px+px, top,m_shadow_color);
-    quads->add(start_px+py, top, start_px+py, top+height,end_px, top+height, end_px, top,m_shadow_color);
+    quads->add(start_px,top,start_px,top+height,start_px+px, top+height, start_px+px, top,m_shadow_color.rgba());
+    quads->add(start_px+py, top, start_px+py, top+height,end_px, top+height, end_px, top,m_shadow_color.rgba());
 
-    lines->add(start_px+px, top, start_px+py, top,m_line_color);
-    lines->add(start_px+px, top+height+1, start_px+py, top+height+1,m_line_color);
+    lines->add(start_px+px, top, start_px+py, top,m_line_color.rgba());
+    lines->add(start_px+px, top+height+1, start_px+py, top+height+1,m_line_color.rgba());
 }
 
 gFooBar::gFooBar(int offset,QColor handle_color,QColor line_color)
diff --git a/Graphs/gFooBar.h b/Graphs/gFooBar.h
index 55eaae98..9e0a7d2c 100644
--- a/Graphs/gFooBar.h
+++ b/Graphs/gFooBar.h
@@ -21,8 +21,8 @@ class gShadowArea:public Layer
     protected:
         QColor m_shadow_color;
         QColor m_line_color;
-        GLShortBuffer *quads;
-        GLShortBuffer *lines;
+        gVertexBuffer *quads;
+        gVertexBuffer *lines;
 };
 
 /*! \class gFooBar
diff --git a/Graphs/gGraphView.cpp b/Graphs/gGraphView.cpp
index dd9a2712..dcaa1e10 100644
--- a/Graphs/gGraphView.cpp
+++ b/Graphs/gGraphView.cpp
@@ -137,6 +137,243 @@ int GetXHeight(QFont *font)
     return fm.xHeight();
 }
 
+inline quint32 swaporder(quint32 color)
+{
+  return ((color & 0xFF00FF00) |
+         ((color & 0xFF0000) >> 16)|
+         ((color & 0xFF) << 16));
+}
+
+gVertexBuffer::gVertexBuffer(int max,int type)
+:m_max(max), m_type(type), m_cnt(0), m_size(1), m_scissor(false), m_stippled(false), m_stipple(0xffff)
+{
+    buffer=(gVertex *)calloc(max,sizeof(gVertex));
+    m_blendfunc1=GL_SRC_ALPHA;
+    m_blendfunc2=GL_ONE_MINUS_SRC_ALPHA;
+    m_antialias=m_forceantialias=false;
+}
+gVertexBuffer::~gVertexBuffer()
+{
+    free(buffer);
+}
+void gVertexBuffer::setColor(QColor col)
+{
+    m_color=swaporder(col.rgba());
+}
+
+void gVertexBuffer::draw()
+{
+    bool antialias=m_forceantialias || (PROFILE.appearance->antiAliasing() && m_antialias);
+    if (m_stippled) antialias=false;
+    float size=m_size;
+
+    if (antialias) {
+        glEnable(GL_BLEND);
+        glBlendFunc(m_blendfunc1,  m_blendfunc2);
+        if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
+            glEnable(GL_LINE_SMOOTH);
+            glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
+            size+=0.5;
+        } else if (m_type==GL_POLYGON) {
+            glEnable(GL_POLYGON_SMOOTH);
+            glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
+        }
+    }
+    if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
+        if (m_stippled) {
+            glLineStipple(1, m_stipple);
+            //size=1;
+            glEnable(GL_LINE_STIPPLE);
+        } else {
+            //glLineStipple(1, 0xFFFF);
+        }
+        glLineWidth(size);
+
+    } else if (m_type==GL_POINTS) {
+        glPointSize(size);
+    } else if (m_type==GL_POLYGON) {
+        glPolygonMode(GL_BACK,GL_FILL);
+    }
+    if (m_scissor) {
+        glScissor(s_x,s_y,s_width,s_height);
+        glEnable(GL_SCISSOR_TEST);
+    }
+
+    glEnableClientState(GL_VERTEX_ARRAY);
+    glEnableClientState(GL_COLOR_ARRAY);
+    glVertexPointer(2, GL_SHORT, 8, (GLvoid *)buffer);
+    glColorPointer(4, GL_UNSIGNED_BYTE, 8, ((char *)buffer)+4);
+
+    glDrawArrays(m_type, 0, m_cnt);
+
+    glDisableClientState(GL_COLOR_ARRAY);
+    glDisableClientState(GL_VERTEX_ARRAY);
+    m_cnt=0;
+    if (m_scissor) {
+        glDisable(GL_SCISSOR_TEST);
+        m_scissor=false;
+    }
+    if (m_type==GL_POLYGON) {
+        glPolygonMode(GL_BACK,GL_FILL);
+    }
+    if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
+        if (m_stippled) {
+            glDisable(GL_LINE_STIPPLE);
+            glLineStipple(1, 0xFFFF);
+        }
+    }
+
+    if (antialias) {
+        if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
+            glDisable(GL_LINE_SMOOTH);
+        } else if (m_type==GL_POLYGON) {
+            glDisable(GL_POLYGON_SMOOTH);
+        }
+        glDisable(GL_BLEND);
+    }
+}
+void gVertexBuffer::add(GLshort x1, GLshort y1, RGBA color)
+{
+    if (m_cnt<m_max) {
+        gVertex & v=buffer[m_cnt];
+
+        v.color=swaporder(color);
+        v.x=x1;
+        v.y=y1;
+
+        m_cnt++;
+    }
+}
+void gVertexBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, RGBA color)
+{
+    if (m_cnt < (m_max-1)) {
+        gVertex * v=&buffer[m_cnt];
+
+        v->x=x1;
+        v->y=y1;
+        v->color=swaporder(color);
+
+        v++;
+        v->x=x2;
+        v->y=y2;
+        v->color=swaporder(color);
+
+        m_cnt+=2;
+    }
+}
+void gVertexBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3, GLshort y3, GLshort x4, GLshort y4, RGBA color)
+{
+    if (m_cnt < (m_max-3)) {
+        gVertex *v=&buffer[m_cnt];
+
+        v->color=swaporder(color);
+        v->x=x1;
+        v->y=y1;
+        v++;
+
+        v->color=swaporder(color);
+        v->x=x2;
+        v->y=y2;
+
+        v++;
+        v->color=swaporder(color);
+        v->x=x3;
+        v->y=y3;
+
+        v++;
+        v->color=swaporder(color);
+        v->x=x4;
+        v->y=y4;
+
+        m_cnt+=4;
+    }
+}
+
+void gVertexBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3, GLshort y3, GLshort x4, GLshort y4, RGBA color1, RGBA color2)
+{
+    if (m_cnt < (m_max-3)) {
+        gVertex *v=&buffer[m_cnt];
+
+        v->color=swaporder(color1);
+        v->x=x1;
+        v->y=y1;
+        v++;
+
+        v->color=swaporder(color1);
+        v->x=x2;
+        v->y=y2;
+
+        v++;
+        v->color=swaporder(color2);
+        v->x=x3;
+        v->y=y3;
+
+        v++;
+        v->color=swaporder(color2);
+        v->x=x4;
+        v->y=y4;
+
+        m_cnt+=4;
+    }
+}
+void gVertexBuffer::add(GLshort x1, GLshort y1)
+{
+    if (m_cnt<m_max) {
+        gVertex & v=buffer[m_cnt];
+
+        v.color=m_color;
+        v.x=x1;
+        v.y=y1;
+
+        m_cnt++;
+    }
+}
+void gVertexBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
+{
+    if (m_cnt < (m_max-1)) {
+        gVertex * v=&buffer[m_cnt];
+
+        v->x=x1;
+        v->y=y1;
+        v->color=m_color;
+
+        v++;
+        v->x=x2;
+        v->y=y2;
+        v->color=m_color;
+
+        m_cnt+=2;
+    }
+}
+void gVertexBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3, GLshort y3, GLshort x4, GLshort y4)
+{
+    if (m_cnt < (m_max-3)) {
+        gVertex *v=&buffer[m_cnt];
+
+        v->color=m_color;
+        v->x=x1;
+        v->y=y1;
+        v++;
+
+        v->color=m_color;
+        v->x=x2;
+        v->y=y2;
+
+        v++;
+        v->color=m_color;
+        v->x=x3;
+        v->y=y3;
+
+        v++;
+        v->color=m_color;
+        v->x=x4;
+        v->y=y4;
+
+        m_cnt+=4;
+    }
+}
+
+
 GLBuffer::GLBuffer(int max,int type, bool stippled)
     :m_max(max), m_type(type), m_stippled(stippled)
 {
@@ -153,247 +390,6 @@ GLBuffer::GLBuffer(int max,int type, bool stippled)
 GLBuffer::~GLBuffer()
 {
 }
-///////
-
-void GLShortBuffer::add(GLshort x, GLshort y)
-{
-    if (m_cnt<m_max+2) {
-#ifdef ENABLE_THREADED_DRAWING
-        mutex.lock();
-#endif
-        buffer[m_cnt++]=x;
-        buffer[m_cnt++]=y;
-#ifdef ENABLE_THREADED_DRAWING
-        mutex.unlock();
-#endif
-    } else {
-        qDebug() << "GLBuffer overflow";
-    }
-}
-void GLShortBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
-{
-    if (m_cnt<m_max+4) {
-#ifdef ENABLE_THREADED_DRAWING
-        mutex.lock();
-#endif
-        buffer[m_cnt++]=x1;
-        buffer[m_cnt++]=y1;
-        buffer[m_cnt++]=x2;
-        buffer[m_cnt++]=y2;
-#ifdef ENABLE_THREADED_DRAWING
-        mutex.unlock();
-#endif
-    } else {
-        qDebug() << "GLBuffer overflow";
-    }
-}
-void GLShortBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,GLshort x3, GLshort y3, GLshort x4, GLshort y4)
-{
-    if (m_cnt<m_max+8) {
-#ifdef ENABLE_THREADED_DRAWING
-        mutex.lock();
-#endif
-        buffer[m_cnt++]=x1;
-        buffer[m_cnt++]=y1;
-        buffer[m_cnt++]=x2;
-        buffer[m_cnt++]=y2;
-        buffer[m_cnt++]=x3;
-        buffer[m_cnt++]=y3;
-        buffer[m_cnt++]=x4;
-        buffer[m_cnt++]=y4;
-#ifdef ENABLE_THREADED_DRAWING
-        mutex.unlock();
-#endif
-    } else {
-        qDebug() << "GLBuffer overflow";
-    }
-}
-
-GLShortBuffer::GLShortBuffer(int max,int type, bool stippled)
-    :GLBuffer(max,type,stippled)
-{
-    buffer=(GLshort *)calloc(sizeof(GLshort),max+8);
-    colors=(GLubyte *)calloc(sizeof(GLubyte),max*4+(8*4));
-}
-GLShortBuffer::~GLShortBuffer()
-{
-    if (colors) free(colors);
-    if (buffer) free(buffer);
-}
-
-void GLShortBuffer::add(GLshort x, GLshort y,QColor & color)
-{
-    if (m_cnt<m_max+2) {
-#ifdef ENABLE_THREADED_DRAWING
-        mutex.lock();
-#endif
-        buffer[m_cnt++]=x;
-        buffer[m_cnt++]=y;
-        colors[m_colcnt++]=color.red();
-        colors[m_colcnt++]=color.green();
-        colors[m_colcnt++]=color.blue();
-        colors[m_colcnt++]=color.alpha();
-#ifdef ENABLE_THREADED_DRAWING
-        mutex.unlock();
-#endif
-    } else {
-        qDebug() << "GLBuffer overflow";
-    }
-}
-void GLShortBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,QColor & color)
-{
-    if (m_cnt<m_max+4) {
-#ifdef ENABLE_THREADED_DRAWING
-        mutex.lock();
-#endif
-        buffer[m_cnt++]=x1;
-        buffer[m_cnt++]=y1;
-        buffer[m_cnt++]=x2;
-        buffer[m_cnt++]=y2;
-        colors[m_colcnt++]=color.red();
-        colors[m_colcnt++]=color.green();
-        colors[m_colcnt++]=color.blue();
-        colors[m_colcnt++]=color.alpha();
-        colors[m_colcnt++]=color.red();
-        colors[m_colcnt++]=color.green();
-        colors[m_colcnt++]=color.blue();
-        colors[m_colcnt++]=color.alpha();
-#ifdef ENABLE_THREADED_DRAWING
-        mutex.unlock();
-#endif
-    } else {
-        qDebug() << "GLBuffer overflow";
-    }
-}
-void GLShortBuffer::add(GLshort x1, GLshort y1, GLshort x2, GLshort y2,GLshort x3, GLshort y3, GLshort x4, GLshort y4,QColor & color) // add with vertex colors
-{
-if (m_cnt<m_max+8) {
-#ifdef ENABLE_THREADED_DRAWING
-    mutex.lock();
-#endif
-    buffer[m_cnt++]=x1;
-    buffer[m_cnt++]=y1;
-    buffer[m_cnt++]=x2;
-    buffer[m_cnt++]=y2;
-    buffer[m_cnt++]=x3;
-    buffer[m_cnt++]=y3;
-    buffer[m_cnt++]=x4;
-    buffer[m_cnt++]=y4;
-    colors[m_colcnt++]=color.red();
-    colors[m_colcnt++]=color.green();
-    colors[m_colcnt++]=color.blue();
-    colors[m_colcnt++]=color.alpha();
-    colors[m_colcnt++]=color.red();
-    colors[m_colcnt++]=color.green();
-    colors[m_colcnt++]=color.blue();
-    colors[m_colcnt++]=color.alpha();
-
-    colors[m_colcnt++]=color.red();
-    colors[m_colcnt++]=color.green();
-    colors[m_colcnt++]=color.blue();
-    colors[m_colcnt++]=color.alpha();
-    colors[m_colcnt++]=color.red();
-    colors[m_colcnt++]=color.green();
-    colors[m_colcnt++]=color.blue();
-    colors[m_colcnt++]=color.alpha();
-#ifdef ENABLE_THREADED_DRAWING
-    mutex.unlock();
-#endif
-} else {
-    qDebug() << "GLBuffer overflow";
-}
-}
-void GLShortBuffer::draw()
-{
-    if (m_cnt>0) {
-        bool antialias=m_forceantialias || (PROFILE.ExistsAndTrue("UseAntiAliasing") && m_antialias);
-        if (m_stippled) antialias=false;
-        float size=m_size;
-
-        if (antialias) {
-            if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
-                glEnable(GL_ALPHA_TEST);
-            } else {
-                glEnable(GL_BLEND);
-                glBlendFunc(m_blendfunc1,  m_blendfunc2);
-            }
-            //glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
-            if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
-                glEnable(GL_LINE_SMOOTH);
-                glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
-                size+=0.5;
-            } else if (m_type==GL_POLYGON) {
-                glEnable(GL_POLYGON_SMOOTH);
-                glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
-            }
-        }
-        if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
-            if (m_stippled) {
-                glLineStipple(1, 0xffff);
-                size=1;
-                glEnable(GL_LINE_STIPPLE);
-            } else {
-                glLineStipple(1, 0xFFFF);
-            }
-            glLineWidth(size);
-
-        } else if (m_type==GL_POINTS) {
-            glPointSize(size);
-        } else if (m_type==GL_POLYGON) {
-            glPolygonMode(GL_BACK,GL_FILL);
-        }
-        if (m_scissor) {
-            glScissor(s1,s2,s3,s4);
-            glEnable(GL_SCISSOR_TEST);
-        }
-
-        glEnableClientState(GL_VERTEX_ARRAY);
-        glVertexPointer(2, GL_SHORT, 0, buffer);
-
-        if (m_colcnt>0) {
-            glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
-            glEnableClientState(GL_COLOR_ARRAY);
-        } else {
-            glColor4ub(m_color.red(),m_color.green(),m_color.blue(),m_color.alpha());
-        }
-        glDrawArrays(m_type, 0, m_cnt >> 1);
-       // glDisableClientState(GL_COLOR_ARRAY);
-        if (m_colcnt>0) {
-            glDisableClientState(GL_COLOR_ARRAY);
-        }
-        glDisableClientState(GL_VERTEX_ARRAY);
-
-        //qDebug() << "I Drawed" << m_cnt << "vertices";
-        m_cnt=0;
-        m_colcnt=0;
-        if (m_scissor) {
-            glDisable(GL_SCISSOR_TEST);
-            m_scissor=false;
-        }
-        if (m_type==GL_POLYGON) {
-            glPolygonMode(GL_BACK,GL_FILL);
-        }
-        if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
-            if (m_stippled) {
-                glDisable(GL_LINE_STIPPLE);
-                glLineStipple(1, 0xFFFF);
-            }
-        }
-
-        if (antialias) {
-            if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
-                glDisable(GL_LINE_SMOOTH);
-            } else if (m_type==GL_POLYGON) {
-                glDisable(GL_POLYGON_SMOOTH);
-            }
-            if (m_type==GL_LINES || m_type==GL_LINE_LOOP) {
-                glDisable(GL_ALPHA_TEST);
-            } else {
-                glDisable(GL_BLEND);
-            }
-        }
-    }
-}
 
 /////////////////////////////////////////////////////////////////////
 // GLFloatBuffer
@@ -778,6 +774,17 @@ void Layer::drawGLBuf(float linesize)
     float size;
     if (!m_visible) return;
     GLBuffer *buf;
+    gVertexBuffer *vb;
+    for (int i=0;i<mv_buffers.size();i++) {
+        vb=mv_buffers[i];
+        size=vb->size();
+        type=vb->type();
+        if ((linesize>size) && ((type==GL_LINES) || (type==GL_LINE_LOOP))) {
+            vb->setSize(linesize);
+        }
+        vb->draw();
+        vb->setSize(size);
+    }
     for (int i=0;i<mgl_buffers.size();i++) {
         buf=mgl_buffers[i];
         size=buf->size();
@@ -991,7 +998,7 @@ gGraph::gGraph(gGraphView *graphview,QString title,QString units, int height,sho
     m_selecting_area=m_blockzoom=false;
     m_lastx23=0;
 
-    m_quad=new GLShortBuffer(64,GL_QUADS);
+    m_quad=new gVertexBuffer(64,GL_QUADS);
     m_quad->forceAntiAlias(true);
     f_miny=f_maxy=0;
     m_enforceMinY=m_enforceMaxY=false;
@@ -1172,8 +1179,8 @@ void gGraph::paint(int originX, int originY, int width, int height)
 
     if (m_selection.width()>0 && m_selecting_area) {
         QColor col(128,128,255,128);
-        quads()->add(originX+m_selection.x(),originY+top, originX+m_selection.x()+m_selection.width(),originY+top,col);
-        quads()->add(originX+m_selection.x()+m_selection.width(),originY+height-bottom, originX+m_selection.x(),originY+height-bottom,col);
+        quads()->add(originX+m_selection.x(),originY+top, originX+m_selection.x()+m_selection.width(),originY+top,col.rgba());
+        quads()->add(originX+m_selection.x()+m_selection.width(),originY+height-bottom, originX+m_selection.x(),originY+height-bottom,col.rgba());
     }
 }
 void gGraphView::queGraph(gGraph * g,int left, int top, int width, int height)
@@ -1666,22 +1673,25 @@ void gGraph::SetMaxY(EventDataType v)
 {
     rmax_y=max_y=v;
 }
-GLShortBuffer * gGraph::lines()
+gVertexBuffer * gGraph::lines()
 {
     return m_graphview->lines;
 }
-GLShortBuffer * gGraph::backlines()
+gVertexBuffer * gGraph::backlines()
 {
     return m_graphview->backlines;
 }
-GLShortBuffer * gGraph::quads()
+gVertexBuffer * gGraph::quads()
 {
     return m_graphview->quads;
 }
-GLShortBuffer * gGraph::stippled()
-{
-    return m_graphview->stippled;
-}
+//GLShortBuffer * gGraph::stippled()
+//{
+//    return m_graphview->stippled;
+//}
+//gVertexBuffer * gGraph::vlines()
+//{ return m_graphview->vlines; } // testing new vertexbuffer
+
 short gGraph::marginLeft() { return m_marginleft; }//*m_graphview->printScaleX(); }
 short gGraph::marginRight() { return m_marginright; } //*m_graphview->printScaleX(); }
 short gGraph::marginTop() { return m_margintop; } //*m_graphview->printScaleY(); }
@@ -1862,13 +1872,16 @@ gGraphView::gGraphView(QWidget *parent, gGraphView * shared) :
         //gt->start();
     }*/
 
-    lines=new GLShortBuffer(100000,GL_LINES); // big fat shared line list
-    backlines=new GLShortBuffer(10000,GL_LINES); // big fat shared line list
-    quads=new GLShortBuffer(1024,GL_QUADS); // big fat shared line list
+    lines=new gVertexBuffer(100000,GL_LINES); // big fat shared line list
+    backlines=new gVertexBuffer(10000,GL_LINES); // big fat shared line list
+    quads=new gVertexBuffer(1024,GL_QUADS); // big fat shared line list
     quads->forceAntiAlias(true);
-    stippled=new GLShortBuffer(20000,GL_LINES,true);
-    stippled->setSize(1.5);
-    stippled->forceAntiAlias(false);
+    frontlines=new gVertexBuffer(20000,GL_LINES);
+
+    //vlines=new gVertexBuffer(20000,GL_LINES);
+
+    //stippled->setSize(1.5);
+    //stippled->forceAntiAlias(false);
     //lines->setSize(1.5);
     //backlines->setSize(1.5);
 
@@ -1905,7 +1918,9 @@ gGraphView::~gGraphView()
     }
     delete m_tooltip;
     m_graphs.clear();
-    delete stippled;
+    //delete vlines;
+    //delete stippled;
+    delete frontlines;
     delete lines;
     delete backlines;
     delete quads;
@@ -2423,11 +2438,11 @@ bool gGraphView::renderGraphs()
             if (m_showsplitter) {
                 // draw the splitter handle
                 QColor ca=QColor(128,128,128,255);
-                backlines->add(0, py+h, w, py+h, ca);
+                backlines->add(0, py+h, w, py+h, ca.rgba());
                 ca=QColor(192,192,192,255);
-                backlines->add(0, py+h+1, w, py+h+1, ca);
+                backlines->add(0, py+h+1, w, py+h+1, ca.rgba());
                 ca=QColor(90,90,90,255);
-                backlines->add(0, py+h+2, w, py+h+2, ca);
+                backlines->add(0, py+h+2, w, py+h+2, ca.rgba());
             }
 
         }
@@ -2458,9 +2473,8 @@ bool gGraphView::renderGraphs()
     }
 #endif
     //int elapsed=time.elapsed();
-    QColor col=Qt::black;
+    //QColor col=Qt::black;
 
-    stippled->draw();
     backlines->draw();
     for (int i=0;i<m_graphs.size();i++) {
         m_graphs[i]->drawGLBuf();
@@ -2670,7 +2684,7 @@ void gGraphView::paintGL()
         int w,h;
         GetTextExtent(ss,w,h);
         QColor col=Qt::white;
-        quads->add(width()-m_graphs[0]->marginRight(),0,width()-m_graphs[0]->marginRight(),w,width(),w,width(),0,col);
+        quads->add(width()-m_graphs[0]->marginRight(),0,width()-m_graphs[0]->marginRight(),w,width(),w,width(),0,col.rgba());
         quads->draw();
         AddTextQue(ss,width()+3,w/2,90,col,defaultfont);
         DrawTextQue();
diff --git a/Graphs/gGraphView.h b/Graphs/gGraphView.h
index 8e7af577..df66e727 100644
--- a/Graphs/gGraphView.h
+++ b/Graphs/gGraphView.h
@@ -53,6 +53,95 @@ class gGraph;
 
 const int textque_max=512;
 
+typedef quint32 RGBA;
+/*union RGBA {
+   struct {
+        GLubyte red;
+        GLubyte green;
+        GLubyte blue;
+        GLubyte alpha;
+    } bytes;
+    quint32 value;
+}; */
+
+#ifdef BUILD_WITH_MSVC
+__declspec(align(1))
+#endif
+struct gVertex
+{
+    gVertex(GLshort _x, GLshort _y, GLuint _c) { x=_x; y=_y; color=_c; }
+    GLshort x;
+    GLshort y;
+    RGBA color;
+}
+#ifndef BUILD_WITH_MSVC
+__attribute__((packed))
+#endif
+;
+
+class gVertexBuffer
+{
+public:
+    gVertexBuffer(int max=2048,int type=GL_LINES);
+    ~gVertexBuffer();
+
+    void add(GLshort x1, GLshort y1, RGBA color);
+    void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, RGBA color);
+    void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3, GLshort y3, GLshort x4, GLshort y4, RGBA color);
+    void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3, GLshort y3, GLshort x4, GLshort y4, RGBA color, RGBA color2);
+
+    void add(GLshort x1, GLshort y1);
+    void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2);
+    void add(GLshort x1, GLshort y1, GLshort x2, GLshort y2, GLshort x3, GLshort y3, GLshort x4, GLshort y4);
+
+    void draw();
+
+    void scissor(GLshort x, GLshort y, GLshort width, GLshort height) { s_x=x; s_y=y; s_width=width; s_height=height; m_scissor=true; }
+
+    void reset() { m_cnt=0; }
+    int Max() { return m_max; }
+    int cnt() { return m_cnt; }
+    GLuint type() { return m_type; }
+    float size() { return m_size; }
+    bool full() { return m_cnt>=m_max; }
+
+    void forceAntiAlias(bool b) { m_forceantialias=b; }
+    void setSize(float f) { m_size=f; }
+    void setAntiAlias(bool b) { m_antialias=b; }
+    void setStipple(GLshort stipple) { m_stipple=stipple; }
+    void setStippleOn(bool b) { m_stippled=b; }
+    void setColor(QColor col);
+    void setBlendFunc(GLuint b1, GLuint b2) { m_blendfunc1=b1; m_blendfunc2=b2; }
+
+protected:
+    //! \brief Maximum number of gVertex points contained in buffer
+    int m_max;
+    //! \brief Indicates type of GL vertex information (GL_LINES, GL_QUADS, etc)
+    GLuint m_type;
+    //! \brief Count of Vertex points used this draw cycle.
+    int m_cnt;
+    //! \brief Line/Point thickness
+    float m_size;
+
+    bool m_scissor;
+    bool m_antialias;
+    bool m_forceantialias;
+    bool m_stippled;
+
+    //! \brief Contains list of Vertex & Color points
+    gVertex * buffer;
+    //! \brief GL Scissor parameters
+    GLshort s_x,s_y,s_width,s_height;
+    //! \brief Current drawing color
+    GLuint m_color;
+    //! \brief Stipple bitfield
+    GLshort m_stipple;
+    //! \brief Source GL Blend Function
+    GLuint m_blendfunc1;
+    //! \brief Destination GL Blend Function
+    GLuint m_blendfunc2;
+};
+
 /*! \class GLBuffer
     \brief Base Object to hold an OpenGL draw list
     */
@@ -90,9 +179,8 @@ protected:
     GLuint m_blendfunc1, m_blendfunc2;
 };
 
-/*! \class GLShortBuffer
+/* ! \class GLShortBuffer
     \brief Holds an OpenGL draw list composed of 16bit integers and vertex colors
-    */
 class GLShortBuffer:public GLBuffer
 {
 public:
@@ -117,6 +205,7 @@ protected:
     GLshort * buffer;
     GLubyte * colors;
 };
+    */
 
 /*! \class GLFloatBuffer
     \brief Holds an OpenGL draw list composed of 32bit GLfloat objects and vertex colors
@@ -268,6 +357,7 @@ public:
 protected:
     //! \brief Add a GLBuffer (vertex) object customized to this layer
     void addGLBuf(GLBuffer *buf) { mgl_buffers.push_back(buf); }
+    void addVertexBuffer(gVertexBuffer *buf) { mv_buffers.push_back(buf); }
     //QRect bounds; // bounds, relative to top of individual graph.
     Day *m_day;
     bool m_visible;
@@ -284,6 +374,7 @@ protected:
 
     //! \brief A vector containing all this layers custom drawing buffers
     QVector<GLBuffer *> mgl_buffers;
+    QVector<gVertexBuffer *> mv_buffers;
 
     //! \brief Mouse wheel moved somewhere over this layer
     virtual bool wheelEvent(QWheelEvent * event) { Q_UNUSED(event); return false; }
@@ -605,14 +696,20 @@ public:
     //! \brief Returns this graphs bottom margin
     short marginBottom();
 
-    //! \brief Returns the main gGraphView objects GLShortBuffer line list.
-    GLShortBuffer * lines();
-    //! \brief Returns the main gGraphView objects GLShortBuffer background line list.
-    GLShortBuffer * backlines();
-    //! \brief Returns the main gGraphView objects GLShortBuffer quads list.
-    GLShortBuffer * quads();
-    //! \brief Returns the main gGraphView objects GLShortBuffer stippled line list.
-    GLShortBuffer * stippled();
+    //! \brief Returns the main gGraphView objects gVertexBuffer line list.
+    gVertexBuffer * lines();
+    //! \brief Returns the main gGraphView objects gVertexBuffer background line list.
+    gVertexBuffer * backlines();
+    //! \brief Returns the main gGraphView objects gVertexBuffer front line list.
+    gVertexBuffer * frontlines();
+    //! \brief Returns the main gGraphView objects gVertexBuffer quads list.
+    gVertexBuffer * quads();
+
+    // //! \brief Returns the main gGraphView objects gVertexBuffer stippled line list.
+    //GLShortBuffer * stippled();
+
+    //gVertexBuffer * vlines(); // testing new vertexbuffer
+
     short left,right,top,bottom; // dirty magin hacks..
 
     Layer * getLineChart();
@@ -666,7 +763,7 @@ protected:
     short m_group;
     short m_lastx23;
     Day * m_day;
-    GLBuffer * m_quad;
+    gVertexBuffer * m_quad;
     bool m_enforceMinY,m_enforceMaxY;
     bool m_showTitle;
     bool m_printing;
@@ -829,7 +926,7 @@ public:
     //! \brief Sends day object to be distributed to all Graphs Layers objects
     void setDay(Day * day);
 
-    GLShortBuffer * lines, * backlines, *quads, * stippled;
+    gVertexBuffer *lines, *backlines, *quads, *frontlines;
 
     //! \brief pops a graph off the list for multithreaded drawing code
     gGraph * popGraph(); // exposed for multithreaded drawing
diff --git a/Graphs/gLineChart.cpp b/Graphs/gLineChart.cpp
index 71ed5e3d..77df26ea 100644
--- a/Graphs/gLineChart.cpp
+++ b/Graphs/gLineChart.cpp
@@ -18,15 +18,13 @@ gLineChart::gLineChart(ChannelID code,QColor col,bool square_plot, bool disable_
     addPlot(code,col,square_plot);
     m_line_color=col;
     m_report_empty=false;
-    addGLBuf(lines=new GLShortBuffer(100000,GL_LINES));
+    addVertexBuffer(lines=new gVertexBuffer(100000,GL_LINES));
     lines->setColor(col);
     lines->setAntiAlias(true);
     lines->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 }
 gLineChart::~gLineChart()
 {
-    //delete lines;
-    //delete outlines;
 }
 
 bool gLineChart::isEmpty()
@@ -162,8 +160,8 @@ void gLineChart::paint(gGraph & w,int left, int top, int width, int height)
     int minz,maxz;
 
     // Draw bounding box
-    GLShortBuffer *outlines=w.lines();
-    QColor blk=Qt::black;
+    gVertexBuffer *outlines=w.lines();
+    GLuint blk=QColor(Qt::black).rgba();
     outlines->add(left, top, left, top+height, blk);
     outlines->add(left, top+height, left+width,top+height, blk);
     outlines->add(left+width,top+height, left+width, top, blk);
@@ -183,9 +181,12 @@ void gLineChart::paint(gGraph & w,int left, int top, int width, int height)
     int legendx=left+width;
 
     int codepoints;
+    //GLuint color;
     for (int gi=0;gi<m_codes.size();gi++) {
         ChannelID code=m_codes[gi];
-        m_line_color=m_colors[gi];
+        //m_line_color=m_colors[gi];
+        lines->setColor(m_colors[gi]);
+        //color=m_line_color.rgba();
 
         codepoints=0;
         for (int svi=0;svi<m_day->size();svi++) {
@@ -393,7 +394,7 @@ void gLineChart::paint(gGraph & w,int left, int top, int width, int height)
                            // ay1=(m_drawlist[i-1].y()+m_drawlist[i].y()+m_drawlist[i+1].y())/3.0;
                             ax1=m_drawlist[i].x();
                             ay1=m_drawlist[i].y();
-                            lines->add(xst+i,yst-ax1,xst+i,yst-ay1,m_line_color);
+                            lines->add(xst+i,yst-ax1,xst+i,yst-ay1);
 
                             if (lines->full()) break;
                         }
@@ -422,7 +423,7 @@ void gLineChart::paint(gGraph & w,int left, int top, int width, int height)
                                 firstpx=false;
                                 continue;
                             }
-                            lines->add(lastpx,lastpy,px,py,m_line_color);
+                            lines->add(lastpx,lastpy,px,py);
 
                             if (lines->full()) {
                                 done=true;
@@ -457,7 +458,7 @@ void gLineChart::paint(gGraph & w,int left, int top, int width, int height)
                         px=xst+((time2 - minx) * xmult);
                         if (px>xst+width) px=xst+width;
 
-                        lines->add(lastpx,lastpy,px,py,m_line_color);
+                        lines->add(lastpx,lastpy,px,py);
                     } else*/
                     for (int i=0;i<siz;i++) {
 
@@ -485,15 +486,15 @@ void gLineChart::paint(gGraph & w,int left, int top, int width, int height)
                                 if (lastpx<xst) lastpx=xst;
                                 if (px>xst+width) px=xst+width;
                                 if (square_plot) {
-                                    lines->add(lastpx,lastpy,px,lastpy,px,lastpy,px,py,m_line_color);
+                                    lines->add(lastpx,lastpy,px,lastpy,px,lastpy,px,py);
                                 } else {
-                                    lines->add(lastpx,lastpy,px,py,m_line_color);
+                                    lines->add(lastpx,lastpy,px,py);
                                 }
                             } else {
                                 if (square_plot) {
-                                    lines->add(lastpx,lastpy,px,lastpy,px,lastpy,px,py,m_line_color);
+                                    lines->add(lastpx,lastpy,px,lastpy,px,lastpy,px,py);
                                 } else {
-                                    lines->add(lastpx,lastpy,px,py,m_line_color);
+                                    lines->add(lastpx,lastpy,px,py);
                                 }
                             }
 
@@ -528,7 +529,7 @@ void gLineChart::paint(gGraph & w,int left, int top, int width, int height)
             legendx-=bw/2;
 
             int tp=top-5-bw/2;
-            w.quads()->add(legendx-bw,tp+bw/2,legendx,tp+bw/2,legendx,tp-bw/2,legendx-bw,tp-bw/2,m_line_color);
+            w.quads()->add(legendx-bw,tp+bw/2,legendx,tp+bw/2,legendx,tp-bw/2,legendx-bw,tp-bw/2,m_line_color.rgba());
             legendx-=hi+bw/2;
         }
     }
@@ -551,7 +552,7 @@ AHIChart::AHIChart(const QColor col)
 :Layer(NoChannel),m_color(col)
 {
     m_miny=m_maxy=0;
-    addGLBuf(lines=new GLShortBuffer(100000,GL_LINES));
+    addVertexBuffer(lines=new gVertexBuffer(100000,GL_LINES));
     lines->setColor(col);
     lines->setAntiAlias(true);
     lines->setSize(1.5);
@@ -570,8 +571,8 @@ void AHIChart::paint(gGraph & w,int left, int top, int width, int height)
         return;
 
     // Draw bounding box
-    GLShortBuffer *outlines=w.lines();
-    QColor blk=Qt::black;
+    gVertexBuffer *outlines=w.lines();
+    GLuint blk=QColor(Qt::black).rgba();
     outlines->add(left, top, left, top+height, blk);
     outlines->add(left, top+height, left+width,top+height, blk);
     outlines->add(left+width,top+height, left+width, top, blk);
@@ -600,6 +601,7 @@ void AHIChart::paint(gGraph & w,int left, int top, int width, int height)
     double lastpx,lastpy;
     double top1=top+height;
     bool done=false;
+    GLuint color=m_color.rgba();
     for (int i=0;i<m_time.size();i++) {
         qint64 ti=m_time[i];
         EventDataType v=m_data[i];
@@ -617,7 +619,7 @@ void AHIChart::paint(gGraph & w,int left, int top, int width, int height)
         } else {
            px=left+(double(ti-minx)*xmult);
            py=top1-(double(v-miny)*ymult);
-           lines->add(px,py,lastpx,lastpy,m_color);
+           lines->add(px,py,lastpx,lastpy);
         }
         lastpx=px;
         lastpy=py;
diff --git a/Graphs/gLineChart.h b/Graphs/gLineChart.h
index 10f6483a..28832d86 100644
--- a/Graphs/gLineChart.h
+++ b/Graphs/gLineChart.h
@@ -49,7 +49,7 @@ protected:
     EventDataType m_miny;
     EventDataType m_maxy;
     QColor m_color;
-    GLShortBuffer * lines;
+    gVertexBuffer * lines;
 };
 
 /*! \class gLineChart
@@ -116,8 +116,9 @@ protected:
         bool m_disable_accel;
         QColor m_line_color;
 
-        GLShortBuffer * lines;
-        GLShortBuffer * outlines;
+        gVertexBuffer * lines;
+        //GLShortBuffer * lines;
+        //GLShortBuffer * outlines;
 
         //! \brief Used by accelerated waveform plots. Must be >= Screen Resolution (or at least graph width)
         static const int max_drawlist_size=10000;
diff --git a/Graphs/gLineOverlay.cpp b/Graphs/gLineOverlay.cpp
index b841efd8..019aeec5 100644
--- a/Graphs/gLineOverlay.cpp
+++ b/Graphs/gLineOverlay.cpp
@@ -11,10 +11,10 @@
 gLineOverlayBar::gLineOverlayBar(ChannelID code,QColor color,QString label,FlagType flt)
 :Layer(code),m_flag_color(color),m_label(label),m_flt(flt)
 {
-    addGLBuf(points=new GLShortBuffer(2048,GL_POINTS));
+    addVertexBuffer(points=new gVertexBuffer(2048,GL_POINTS));
     points->setSize(4);
     points->setColor(m_flag_color);
-    addGLBuf(quads=new GLShortBuffer(2048,GL_QUADS));
+    addVertexBuffer(quads=new gVertexBuffer(2048,GL_QUADS));
     //addGLBuf(lines=new GLBuffer(color,1024,GL_LINES));
     points->setAntiAlias(true);
     quads->setAntiAlias(true);
@@ -33,7 +33,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
     if (!m_visible) return;
     if (!m_day) return;
 
-    lines=w.lines();
+    gVertexBuffer * lines=w.lines();
     int start_py=topp;
 
     double xx=w.max_x-w.min_x;
@@ -56,10 +56,13 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
     m_sum=0;
     m_flag_color=schema::channel[m_code].defaultColor();
 
+    lines->setColor(m_flag_color);
+    points->setColor(m_flag_color);
     if (m_flt==FT_Span) {
         m_flag_color.setAlpha(128);
     }
     EventStoreType raw;
+
     for (QVector<Session *>::iterator s=m_day->begin();s!=m_day->end(); s++) {
         if (!(*s)->enabled()) continue;
         cei=(*s)->eventlist.find(m_code);
@@ -92,7 +95,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
                 if (x2<left) x2=left;
                 if (x1>width+left) x1=width+left;
                 //double w1=x2-x1;
-                quads->add(x2,start_py, x1,start_py, x1,start_py+height, x2,start_py+height,m_flag_color);
+                quads->add(x2,start_py, x1,start_py, x1,start_py+height, x2,start_py+height,m_flag_color.rgba());
                 if (quads->full()) { verts_exceeded=true; break; }
             } else if (m_flt==FT_Dot) {
                 if ((PROFILE.appearance->overlayType()==ODT_Bars) || (xx<3600000)) {
@@ -101,7 +104,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
                     if (points->full()) { verts_exceeded=true; break; }
                 } else {
                     // thin lines down the bottom
-                    lines->add(x1,start_py+1,x1,start_py+1+12,m_flag_color);
+                    lines->add(x1,start_py+1,x1,start_py+1+12);
                     if (lines->full()) { verts_exceeded=true; break; }
 
                 }
@@ -111,10 +114,10 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh
                     z=top;
 
                     points->add(x1,top);
-                    lines->add(x1,top,x1,bottom,m_flag_color);
+                    lines->add(x1,top,x1,bottom);
                     if (points->full()) { verts_exceeded=true; break; }
                } else {
-                    lines->add(x1,z,x1,z-12,m_flag_color);
+                    lines->add(x1,z,x1,z-12);
                }
                if (lines->full()) { verts_exceeded=true; break; }
                if (xx<(1800000)) {
diff --git a/Graphs/gLineOverlay.h b/Graphs/gLineOverlay.h
index a701c4c6..c73cef2a 100644
--- a/Graphs/gLineOverlay.h
+++ b/Graphs/gLineOverlay.h
@@ -40,7 +40,8 @@ class gLineOverlayBar:public Layer
         int m_count;
         double m_sum;
 
-        GLShortBuffer *points,*quads, *lines;
+        gVertexBuffer *quads;
+        gVertexBuffer *points;
 };
 
 /*! \class gLineOverlaySummary
diff --git a/Graphs/gSegmentChart.cpp b/Graphs/gSegmentChart.cpp
index da84fa40..a26cd343 100644
--- a/Graphs/gSegmentChart.cpp
+++ b/Graphs/gSegmentChart.cpp
@@ -100,8 +100,8 @@ void gSegmentChart::paint(gGraph & w,int left, int top, int width, int height)
     bool line_first=true;
     int line_last;
 
-    GLShortBuffer *quads=w.quads();
-    GLShortBuffer *lines2=w.lines();
+    gVertexBuffer *quads=w.quads();
+    gVertexBuffer *lines2=w.lines();
     for (unsigned m=0;m<size;m++) {
         data=m_values[m];
 
@@ -157,11 +157,11 @@ void gSegmentChart::paint(gGraph & w,int left, int top, int width, int height)
             QColor & col=m_colors[m % m_colors.size()];
             float bw=xmult*float(data);
 
-            quads->add(xp,start_py,xp+bw,start_py,m_gradient_color);
-            quads->add(xp+bw,start_py+height,xp,start_py+height,col);
+            quads->add(xp,start_py,xp+bw,start_py,m_gradient_color.rgba());
+            quads->add(xp+bw,start_py+height,xp,start_py+height,col.rgba());
 
-            lines2->add(xp,start_py,xp+bw,start_py,m_outline_color);
-            lines2->add(xp+bw,start_py+height,xp,start_py+height,m_outline_color);
+            lines2->add(xp,start_py,xp+bw,start_py,m_outline_color.rgba());
+            lines2->add(xp+bw,start_py+height,xp,start_py+height,m_outline_color.rgba());
 
             if (!m_names[m].isEmpty()) {
                 int px,py;
diff --git a/Graphs/gSegmentChart.h b/Graphs/gSegmentChart.h
index b9399fde..c35cabd8 100644
--- a/Graphs/gSegmentChart.h
+++ b/Graphs/gSegmentChart.h
@@ -51,6 +51,8 @@ protected:
     QColor m_gradient_color;
     QColor m_outline_color;
     bool m_empty;
+
+    // gah.. can't convert these
     GLFloatBuffer *poly,*lines;
 };
 
diff --git a/Graphs/gSummaryChart.cpp b/Graphs/gSummaryChart.cpp
index 0c17e0d1..de599ca3 100644
--- a/Graphs/gSummaryChart.cpp
+++ b/Graphs/gSummaryChart.cpp
@@ -15,11 +15,11 @@ SummaryChart::SummaryChart(QString label,GraphType type)
 :Layer(NoChannel),m_label(label),m_graphtype(type)
 {
     //QColor color=Qt::black;
-    addGLBuf(quads=new GLShortBuffer(20000,GL_QUADS));
-    addGLBuf(lines=new GLShortBuffer(20000,GL_LINES));
+    addVertexBuffer(quads=new gVertexBuffer(20000,GL_QUADS));
+    addVertexBuffer(lines=new gVertexBuffer(20000,GL_LINES));
     quads->forceAntiAlias(true);
-    lines->setSize(1.5);
-    lines->setBlendFunc(GL_ONE, GL_ONE);
+    lines->setSize(2);
+    lines->setBlendFunc(GL_SRC_COLOR, GL_ZERO);
     lines->forceAntiAlias(false);
 
     m_empty=true;
@@ -313,10 +313,10 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
     if (!m_visible) return;
 
     rtop=top;
-    GLShortBuffer *outlines=w.lines();
-    QColor blk=Qt::black;
-    outlines->add(left, top, left, top+height, left, top+height, left+width,top+height, blk);
-    outlines->add(left+width,top+height, left+width, top, left+width, top, left, top, blk);
+    gVertexBuffer *outlines=w.lines();
+    outlines->setColor(Qt::black);
+    outlines->add(left, top, left, top+height, left, top+height, left+width,top+height);
+    outlines->add(left+width,top+height, left+width, top, left+width, top, left, top);
     //if (outlines->full()) qDebug() << "WTF??? Outlines full in SummaryChart::paint()";
 
     qint64 minx=w.min_x, maxx=w.max_x;
@@ -439,7 +439,7 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
             if (x2<x1)
                 goto jumpnext;
                 //continue;
-            ChannelID code;
+            //ChannelID code;
 
             if (m_graphtype==GT_SESSIONS) {
                 int j;
@@ -450,7 +450,9 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
                 if (zd==hl_day) {
                     col=QColor("gold");
                 }
-                QColor col2=brighten(col);
+                GLuint col1=col.rgba();
+                GLuint col2=brighten(col).rgba();
+                outlines->setColor(Qt::black);
 
                 for (j=0;j<d.value().size();j++) {
                     tmp2=times.value()[j]-miny;
@@ -461,11 +463,10 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
                     //tmp-=miny;
                     h=tmp*ymult;
 
-                    quads->add(x1,py,x1,py-h,col);
-                    quads->add(x2,py-h,x2,py,col2);
+                    quads->add(x1,py,x1,py-h,x2,py-h,x2,py,col1,col2);
                     if (h>0 && barw>2) {
-                        outlines->add(x1,py,x1,py-h,x1,py-h,x2,py-h,blk);
-                        outlines->add(x1,py,x2,py,x2,py,x2,py-h,blk);
+                        outlines->add(x1,py,x1,py-h,x1,py-h,x2,py-h);
+                        outlines->add(x1,py,x2,py,x2,py,x2,py-h);
                     } // if (bar
                     //py-=h;
                     totalvalues[0]+=tmp;
@@ -526,18 +527,21 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
                     h=tmp*ymult; // height in pixels
 
                     if (m_graphtype==GT_BAR) {
-                        QColor col2=brighten(col);
+                        GLuint col1=col.rgba();
+                        GLuint col2=brighten(col).rgba();
 
-                        quads->add(x1,py,x1,py-h,col);
+                        quads->add(x1,py,x1,py-h,col1);
                         quads->add(x2,py-h,x2,py,col2);
                         if (h>0 && barw>2) {
-                            outlines->add(x1,py,x1,py-h,x1,py-h,x2,py-h,blk);
-                            outlines->add(x1,py,x2,py,x2,py,x2,py-h,blk);
+                            outlines->add(x1,py,x1,py-h,x1,py-h,x2,py-h);
+                            outlines->add(x1,py,x2,py,x2,py,x2,py-h);
                             if (outlines->full()) qDebug() << "WTF??? Outlines full in SummaryChart::paint()";
                         } // if (bar
                         py-=h;
                     } else if (m_graphtype==GT_LINE) { // if (m_graphtype==GT_BAR
                         col.setAlpha(128);
+                        GLuint col1=col.rgba();
+                        GLuint col2=m_colors[j].rgba();
                         px2=px+barw;
                         py2=(top+height-2)-h;
                         //py2+=j;
@@ -547,11 +551,12 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height)
                             lastdaygood=false;
                         }
                         if (lastdaygood) {
-                            if (lastY[j]!=py2) // vertical line
-                                lines->add(lastX[j],lastY[j],px,py2,m_colors[j]);
-                            lines->add(px-1,py2,px2+1,py2,col);
+                            if (lastY[j]!=py2) {// vertical line
+                                lines->add(lastX[j],lastY[j],px,py2,col2);
+                            }
+                            lines->add(px-1,py2,px2+1,py2,col1);
                         } else {
-                            lines->add(x1-1,py2,x2+1,py2,col);
+                            lines->add(x1-1,py2,x2+1,py2,col1);
                         }
                         lastX[j]=px2;
                         lastY[j]=py2;
@@ -629,7 +634,7 @@ jumpnext:
         float wt=20*w.printScaleX();
         px-=wt+x;
         w.renderText(a,px+wt,py+1);
-        quads->add(px+wt-y/4-y,py-y,px+wt-y/4,py-y,px+wt-y/4,py+1,px+wt-y/4-y,py+1,m_colors[j]);
+        quads->add(px+wt-y/4-y,py-y,px+wt-y/4,py-y,px+wt-y/4,py+1,px+wt-y/4-y,py+1,m_colors[j].rgba());
         //lines->add(px,py,px+20,py,m_colors[j]);
         //lines->add(px,py+1,px+20,py+1,m_colors[j]);
     }
diff --git a/Graphs/gSummaryChart.h b/Graphs/gSummaryChart.h
index cde81df2..ae4ee797 100644
--- a/Graphs/gSummaryChart.h
+++ b/Graphs/gSummaryChart.h
@@ -71,8 +71,8 @@ class SummaryChart:public Layer
         QHash<int,EventDataType> m_hours;
         QHash<int,Day *> m_days;
 
-        GLShortBuffer *quads;
-        GLShortBuffer *lines;
+        gVertexBuffer *quads;
+        gVertexBuffer *lines;
         bool m_empty;
         int m_fday;
         QString m_label;
diff --git a/Graphs/gXAxis.cpp b/Graphs/gXAxis.cpp
index d7dd82b0..676bdd75 100644
--- a/Graphs/gXAxis.cpp
+++ b/Graphs/gXAxis.cpp
@@ -135,8 +135,8 @@ void gXAxis::paint(gGraph & w,int left,int top, int width, int height)
         aligned_start+=step;
     }
 
-    QColor linecol=Qt::black;
-    GLShortBuffer *lines=w.backlines();
+    gVertexBuffer *lines=w.backlines();
+    lines->setColor(Qt::black);
 
 
     //int utcoff=m_utcfix ? tz_hours : 0;
@@ -163,13 +163,13 @@ void gXAxis::paint(gGraph & w,int left,int top, int width, int height)
     for (int i=0;i<num_minor_ticks;i++) {
         py-=step_pixels;
         if (py<start_px) continue;
-        lines->add(py,top,py,mintop,linecol);
+        lines->add(py,top,py,mintop);
     }
 
     for (qint64 i=aligned_start;i<maxx;i+=step) {
         px=(i-minx)*xmult;
         px+=left;
-        lines->add(px,top,px,majtop,linecol);
+        lines->add(px,top,px,majtop);
         qint64 j=i;
         if (!m_utcfix) j+=tz_offset;
         int ms=j % 1000;
@@ -206,7 +206,7 @@ void gXAxis::paint(gGraph & w,int left,int top, int width, int height)
         for (int j=1;j<num_minor_ticks;j++) {
             py+=step_pixels;
             if (py>=left+width) break;
-            lines->add(py,top,py,mintop,linecol);
+            lines->add(py,top,py,mintop);
         }
 
         if (lines->full()) {
diff --git a/Graphs/gYAxis.cpp b/Graphs/gYAxis.cpp
index 47f18cfd..45ebfef8 100644
--- a/Graphs/gYAxis.cpp
+++ b/Graphs/gYAxis.cpp
@@ -31,7 +31,7 @@ gXGrid::~gXGrid()
 }
 void gXGrid::paint(gGraph & w,int left,int top, int width, int height)
 {
-    GLShortBuffer * stippled, * lines;
+    gVertexBuffer * stippled, * lines;
 
     int x,y;
 
@@ -91,13 +91,13 @@ void gXGrid::paint(gGraph & w,int left,int top, int width, int height)
     }
 
 
-    stippled=w.stippled();
+    stippled=w.backlines();
     lines=w.backlines();
     for (double i=miny; i<=maxy+min_ytick-0.00001; i+=min_ytick) {
         ty=(i - miny) * ymult;
         h=top+height-ty;
         if (m_show_major_lines && (i > miny)) {
-            stippled->add(left,h,left+width,h,m_major_color);
+            stippled->add(left,h,left+width,h,m_major_color.rgba());
         }
         double z=(min_ytick/4)*ymult;
         double g=h;
@@ -109,7 +109,7 @@ void gXGrid::paint(gGraph & w,int left,int top, int width, int height)
 //                break;
   //          }
             if (m_show_minor_lines) {// && (i > miny)) {
-                stippled->add(left,g,left+width,g,m_minor_color);
+                stippled->add(left,g,left+width,g,m_minor_color.rgba());
             }
             if (stippled->full()) {
                 break;
@@ -200,7 +200,7 @@ void gYAxis::paint(gGraph & w,int left,int top, int width, int height)
     }
     lines=w.backlines();
 
-
+    GLuint line_color=m_line_color.rgba();
     for (double i=miny; i<=maxy+min_ytick-0.00001; i+=min_ytick) {
         ty=(i - miny) * ymult;
         if (dy<5) {
@@ -216,14 +216,14 @@ void gYAxis::paint(gGraph & w,int left,int top, int width, int height)
         if (h<top) continue;
         w.renderText(fd,left+width-8-x,(h+(y/2.0)),0,m_text_color);
 
-        lines->add(left+width-4,h,left+width,h,m_line_color);
+        lines->add(left+width-4,h,left+width,h,line_color);
 
         double z=(min_ytick/4)*ymult;
         double g=h;
         for (int i=0;i<3;i++) {
             g+=z;
             if (g>top+height) break;
-            lines->add(left+width-3,g,left+width,g,m_line_color);
+            lines->add(left+width-3,g,left+width,g,line_color);
             if (lines->full()) {
                 qWarning() << "vertarray bounds exceeded in gYAxis for " << w.title() << "graph" << "MinY =" <<miny << "MaxY =" << maxy << "min_ytick=" <<min_ytick;
                 break;
diff --git a/Graphs/gYAxis.h b/Graphs/gYAxis.h
index d7c72954..be75bc62 100644
--- a/Graphs/gYAxis.h
+++ b/Graphs/gYAxis.h
@@ -109,7 +109,7 @@ class gYAxis:public Layer
 
         QColor m_line_color;
         QColor m_text_color;
-        GLShortBuffer * lines;
+        gVertexBuffer * lines;
         virtual bool mouseMoveEvent(QMouseEvent * event);
 
 };
diff --git a/SleepLib/profiles.cpp b/SleepLib/profiles.cpp
index a44916ae..b50e43ff 100644
--- a/SleepLib/profiles.cpp
+++ b/SleepLib/profiles.cpp
@@ -12,6 +12,7 @@ License: GPL
 #include <QDir>
 #include <QMessageBox>
 #include <QDebug>
+#include <algorithm>
 
 #include "preferences.h"
 #include "profiles.h"
diff --git a/daily.cpp b/daily.cpp
index d232b611..ca72b7f1 100644
--- a/daily.cpp
+++ b/daily.cpp
@@ -584,7 +584,7 @@ void Daily::on_calendar_selectionChanged()
        // GraphView->fadeOut();
         Unload(previous_date);
     }
-    bool fadedir=previous_date < ui->calendar->selectedDate();
+    //bool fadedir=previous_date < ui->calendar->selectedDate();
     ZombieMeterMoved=false;
     Load(ui->calendar->selectedDate());
     //GraphView->fadeIn(fadedir);
@@ -929,14 +929,11 @@ void Daily::Load(QDate date)
             CPAP_TidalVolume, OXI_Pulse, OXI_SPO2
         };
         int numchans=sizeof(chans)/sizeof(ChannelID);
-        int suboffset=0;
+        //int suboffset=0;
         for (int i=0;i<numchans;i++) {
 
             ChannelID code=chans[i];
             if (cpap && cpap->channelHasData(code)) {
-                if (code==CPAP_RespRate) {
-                    int i=5;
-                }
                 //if (code==CPAP_LeakTotal) suboffset=PROFILEIntentionalLeak"].toDouble(); else suboffset=0;
                 QString tooltip=schema::channel[code].description();
                 if (!schema::channel[code].units().isEmpty()) tooltip+=" ("+schema::channel[code].units()+")";
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 6e6ee1fe..2f6f7bb6 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -2295,9 +2295,3 @@ void MainWindow::on_summaryView_linkClicked(const QUrl &arg1)
     qDebug() << arg1;
     on_recordsBox_linkClicked(arg1);
 }
-
-void MainWindow::on_summaryView_urlChanged(const QUrl &arg1)
-{
-//    qDebug() << arg1;
-//    on_recordsBox_linkClicked(arg1);
-}
diff --git a/mainwindow.h b/mainwindow.h
index a080342c..2be44386 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -275,8 +275,6 @@ private slots:
 
     void on_summaryView_linkClicked(const QUrl &arg1);
 
-    void on_summaryView_urlChanged(const QUrl &arg1);
-
 private:
 
     Ui::MainWindow *ui;