diff -uNbr rosegarden.orig/src/base/Sets.h rosegarden/src/base/Sets.h
--- rosegarden.orig/src/base/Sets.h	2012-02-08 18:36:12.000000000 -0600
+++ rosegarden/src/base/Sets.h	2012-04-13 11:41:04.467490291 -0500
@@ -287,7 +287,7 @@
     m_final = m_baseIterator;
     sample(m_baseIterator, true);
 
-    if (getAsEvent(m_baseIterator)->isa(Note::EventType)) {
+    if (AbstractSet::getAsEvent(m_baseIterator)->isa(Note::EventType)) {
         m_initialNote = m_baseIterator;
         m_finalNote = m_baseIterator;
     }
@@ -300,7 +300,7 @@
     for (i = j = m_baseIterator; i != getContainer().begin() && test(--j); i = j){
         if (sample(j, false)) {
             m_initial = j;
-            if (getAsEvent(j)->isa(Note::EventType)) {
+            if (AbstractSet::getAsEvent(j)->isa(Note::EventType)) {
 		m_initialNote = j;
 		if (m_finalNote == getContainer().end()) {
 		    m_finalNote = j;
@@ -317,7 +317,7 @@
     for (i = j = m_baseIterator; ++j != getContainer().end() && test(j); i = j) {
         if (sample(j, true)) {
             m_final = j;
-            if (getAsEvent(j)->isa(Note::EventType)) {
+            if (AbstractSet::getAsEvent(j)->isa(Note::EventType)) {
 		m_finalNote = j;
 		if (m_initialNote == getContainer().end()) {
 		    m_initialNote = j;
@@ -332,17 +332,17 @@
 AbstractSet<Element, Container>::sample(const Iterator &i, bool)
 {
     const Quantizer &q(getQuantizer());
-    Event *e = getAsEvent(i);
+    Event *e = AbstractSet::getAsEvent(i);
     timeT d(q.getQuantizedDuration(e));
     
     if (e->isa(Note::EventType) || d > 0) {
         if (m_longest == getContainer().end() ||
-            d > q.getQuantizedDuration(getAsEvent(m_longest))) {
+            d > q.getQuantizedDuration(AbstractSet::getAsEvent(m_longest))) {
 //          std::cerr << "New longest in set at duration " << d << " and time " << e->getAbsoluteTime() << std::endl;
             m_longest = i;
         }
         if (m_shortest == getContainer().end() ||
-            d < q.getQuantizedDuration(getAsEvent(m_shortest))) {
+            d < q.getQuantizedDuration(AbstractSet::getAsEvent(m_shortest))) {
 //          std::cerr << "New shortest in set at duration " << d << " and time " << e->getAbsoluteTime() << std::endl;
             m_shortest = i;
         }
@@ -352,12 +352,12 @@
         long p = get__Int(e, BaseProperties::PITCH);
 
         if (m_highest == getContainer().end() ||
-            p > get__Int(getAsEvent(m_highest), BaseProperties::PITCH)) {
+            p > get__Int(AbstractSet::getAsEvent(m_highest), BaseProperties::PITCH)) {
 //          std::cerr << "New highest in set at pitch " << p << " and time " << e->getAbsoluteTime() << std::endl;
             m_highest = i;
         }
         if (m_lowest == getContainer().end() ||
-            p < get__Int(getAsEvent(m_lowest), BaseProperties::PITCH)) {
+            p < get__Int(AbstractSet::getAsEvent(m_lowest), BaseProperties::PITCH)) {
 //          std::cerr << "New lowest in set at pitch " << p << " and time " << e->getAbsoluteTime() << std::endl;
             m_lowest = i;
         }
@@ -376,8 +376,8 @@
                                                             PropertyName stemUpProperty) :
     AbstractSet<Element, Container>(c, i, q),
     m_stemUpProperty(stemUpProperty),
-    m_time(q->getQuantizedAbsoluteTime(getAsEvent(i))),
-    m_subordering(getAsEvent(i)->getSubOrdering()),
+    m_time(q->getQuantizedAbsoluteTime(GenericChord::getAsEvent(i))),
+    m_subordering(GenericChord::getAsEvent(i)->getSubOrdering()),
     m_firstReject(c.end())
 {
     AbstractSet<Element, Container>::initialise();
@@ -416,7 +416,7 @@
 bool
 GenericChord<Element, Container, singleStaff>::test(const Iterator &i)
 {
-    Event *e = getAsEvent(i);
+    Event *e = GenericChord::getAsEvent(i);
     if (AbstractSet<Element, Container>::
 	getQuantizer().getQuantizedAbsoluteTime(e) != m_time) {
 	return false;
@@ -452,7 +452,7 @@
 GenericChord<Element, Container, singleStaff>::sample(const Iterator &i,
                                                       bool goingForwards)
 {
-    Event *e1 = getAsEvent(i);
+    Event *e1 = GenericChord::getAsEvent(i);
     if (!e1->isa(Note::EventType)) {
         if (goingForwards && m_firstReject == AbstractSet<Element, Container>::getContainer().end()) m_firstReject = i;
         return false;
@@ -472,7 +472,7 @@
 
         if (AbstractSet<Element, Container>::m_baseIterator != AbstractSet<Element, Container>::getContainer().end()) {
 
-            Event *e0 = getAsEvent(AbstractSet<Element, Container>::m_baseIterator);
+            Event *e0 = GenericChord::getAsEvent(AbstractSet<Element, Container>::m_baseIterator);
 
             if (!(m_stemUpProperty == PropertyName::EmptyPropertyName)) {
 
@@ -518,7 +518,7 @@
     }
 
     AbstractSet<Element, Container>::sample(i, goingForwards);
-    push_back(i);
+    this->push_back(i);
     return true;
 }
 
@@ -560,7 +560,7 @@
 
     for (unsigned int i = 0; i < std::vector<typename Container::iterator>::size(); ++i) {
 
-        Event *e = getAsEvent((*this)[i]);
+        Event *e = GenericChord::getAsEvent((*this)[i]);
         std::vector<Mark> marks(Marks::getMarks(*e));
 
         for (std::vector<Mark>::iterator j = marks.begin(); j != marks.end(); ++j) {
@@ -580,7 +580,7 @@
 
     for (unsigned int i = 0; i < std::vector<typename Container::iterator>::size(); ++i) {
 
-        Event *e = getAsEvent((*this)[i]);
+        Event *e = GenericChord::getAsEvent((*this)[i]);
         std::vector<Mark> marks(Marks::getMarks(*e));
 
 
@@ -607,9 +607,9 @@
 
     for (typename std::vector<typename Container::iterator>::const_iterator
              i = std::vector<typename Container::iterator>::begin(); i != std::vector<typename Container::iterator>::end(); ++i) {
-        if (getAsEvent(*i)->has(BaseProperties::PITCH)) {
+        if (GenericChord::getAsEvent(*i)->has(BaseProperties::PITCH)) {
             int pitch = get__Int
-                (getAsEvent(*i), BaseProperties::PITCH);
+                (GenericChord::getAsEvent(*i), BaseProperties::PITCH);
             if (pitches.size() > 0 && pitches[pitches.size()-1] == pitch) 
                 continue;
             pitches.push_back(pitch);
@@ -641,7 +641,7 @@
     while (1) {
         if (i == AbstractSet<Element, Container>::getContainer().begin()) return AbstractSet<Element, Container>::getContainer().end();
         --i;
-        if (getAsEvent(i)->isa(Note::EventType)) {
+        if (GenericChord::getAsEvent(i)->isa(Note::EventType)) {
             return i;
         }
     }
@@ -655,7 +655,7 @@
     Iterator i(AbstractSet<Element, Container>::getFinalElement());
     while (  i != AbstractSet<Element, Container>::getContainer().end() &&
            ++i != AbstractSet<Element, Container>::getContainer().end()) {
-        if (getAsEvent(i)->isa(Note::EventType)) {
+        if (GenericChord::getAsEvent(i)->isa(Note::EventType)) {
             return i;
         }
     }
@@ -677,8 +677,8 @@
                                                            const Iterator &b)
 {
     try {
-        long ap = get__Int(getAsEvent(a), BaseProperties::PITCH);
-        long bp = get__Int(getAsEvent(b), BaseProperties::PITCH);
+        long ap = get__Int(GenericChord::getAsEvent(a), BaseProperties::PITCH);
+        long bp = get__Int(GenericChord::getAsEvent(b), BaseProperties::PITCH);
         return (ap < bp);
     } catch (Event::NoData) {
         std::cerr << "Bad karma: PitchGreater failed to find one or both pitches" << std::endl;
diff -uNbr rosegarden.orig/src/document/RosegardenGUIDoc.cpp rosegarden/src/document/RosegardenGUIDoc.cpp
--- rosegarden.orig/src/document/RosegardenGUIDoc.cpp	2012-02-08 18:36:12.000000000 -0600
+++ rosegarden/src/document/RosegardenGUIDoc.cpp	2012-04-13 12:19:40.622563958 -0500
@@ -2106,15 +2106,15 @@
 
         bool meaningless = true;
 
-        for (Segment::iterator i = s->begin(); i != s->end(); ++i) {
+        for (Segment::iterator j = s->begin(); j != s->end(); ++j) {
 
-            if ((*i)->isa(Clef::EventType)) continue;
+            if ((*j)->isa(Clef::EventType)) continue;
 
             // no rests in the segment yet, so anything else is meaningful
             meaningless = false;
 
-            if (!haveMeaning || (*i)->getAbsoluteTime() < earliestMeaning) {
-                earliestMeaning = (*i)->getAbsoluteTime();
+            if (!haveMeaning || (*j)->getAbsoluteTime() < earliestMeaning) {
+                earliestMeaning = (*j)->getAbsoluteTime();
             }
 
             haveMeaning = true;
@@ -2149,13 +2149,13 @@
          ++i) {
 
         Segment *s = i->second;
-        Segment::iterator i = s->begin();
+        Segment::iterator j = s->begin();
 
-        if (i == s->end() || !(*i)->isa(Clef::EventType)) continue;
+        if (j == s->end() || !(*j)->isa(Clef::EventType)) continue;
 
-        if ((*i)->getAbsoluteTime() < meaningfulBarStart) {
-            Event *e = new Event(**i, meaningfulBarStart);
-            s->erase(i);
+        if ((*j)->getAbsoluteTime() < meaningfulBarStart) {
+            Event *e = new Event(**j, meaningfulBarStart);
+            s->erase(j);
             s->insert(e);
         }
     }
diff -uNbr rosegarden.orig/src/gui/application/LircClient.cpp rosegarden/src/gui/application/LircClient.cpp
--- rosegarden.orig/src/gui/application/LircClient.cpp	2012-02-08 18:36:12.000000000 -0600
+++ rosegarden/src/gui/application/LircClient.cpp	2012-04-13 11:47:22.451542455 -0500
@@ -36,6 +36,7 @@
 #include <tqsocketnotifier.h>
 #include <fcntl.h>
 #include <cstdlib>
+#include <unistd.h>
 
 namespace Rosegarden
 {
diff -uNbr rosegarden.orig/src/gui/application/LircCommander.cpp rosegarden/src/gui/application/LircCommander.cpp
--- rosegarden.orig/src/gui/application/LircCommander.cpp	2012-02-08 18:36:12.000000000 -0600
+++ rosegarden/src/gui/application/LircCommander.cpp	2012-04-13 11:47:57.918018023 -0500
@@ -37,7 +37,7 @@
 #include "RosegardenGUIView.h"
 
 #include <tqobject.h>
-
+#include <unistd.h>
 
 namespace Rosegarden
 {
diff -uNbr rosegarden.orig/src/gui/application/main.cpp rosegarden/src/gui/application/main.cpp
--- rosegarden.orig/src/gui/application/main.cpp	2012-02-08 18:36:12.000000000 -0600
+++ rosegarden/src/gui/application/main.cpp	2012-04-13 11:48:21.318332053 -0500
@@ -22,6 +22,7 @@
 #include <tqtimer.h>
 #include <kapplication.h>
 #include <sys/time.h>
+#include <unistd.h>
 #include "base/RealTime.h"
 
 #include <kcmdlineargs.h>
diff -uNbr rosegarden.orig/src/gui/seqmanager/ControlBlockMmapper.cpp rosegarden/src/gui/seqmanager/ControlBlockMmapper.cpp
--- rosegarden.orig/src/gui/seqmanager/ControlBlockMmapper.cpp	2012-02-08 18:36:12.000000000 -0600
+++ rosegarden/src/gui/seqmanager/ControlBlockMmapper.cpp	2012-04-13 13:07:17.493358136 -0500
@@ -42,6 +42,7 @@
 #include <fcntl.h>
 #include <sys/mman.h>
 #include <errno.h>
+#include <unistd.h>
 
 namespace Rosegarden
 {
diff -uNbr rosegarden.orig/src/gui/seqmanager/SegmentMmapper.cpp rosegarden/src/gui/seqmanager/SegmentMmapper.cpp
--- rosegarden.orig/src/gui/seqmanager/SegmentMmapper.cpp	2012-02-08 18:36:12.000000000 -0600
+++ rosegarden/src/gui/seqmanager/SegmentMmapper.cpp	2012-04-13 13:45:31.801671739 -0500
@@ -45,7 +45,7 @@
 #include <fcntl.h>
 #include <sys/mman.h>
 #include <errno.h>
-
+#include <unistd.h>
 
 namespace Rosegarden
 {
diff -uNbr rosegarden.orig/src/gui/seqmanager/SequencerMapper.cpp rosegarden/src/gui/seqmanager/SequencerMapper.cpp
--- rosegarden.orig/src/gui/seqmanager/SequencerMapper.cpp	2012-02-08 18:36:12.000000000 -0600
+++ rosegarden/src/gui/seqmanager/SequencerMapper.cpp	2012-04-13 14:00:52.593865436 -0500
@@ -40,7 +40,7 @@
 #include <fcntl.h>
 #include <sys/mman.h>
 #include <errno.h>
-
+#include <unistd.h>
 
 namespace Rosegarden
 {
diff -uNbr rosegarden.orig/src/gui/studio/AudioPluginManager.cpp rosegarden/src/gui/studio/AudioPluginManager.cpp
--- rosegarden.orig/src/gui/studio/AudioPluginManager.cpp	2012-02-08 18:36:12.000000000 -0600
+++ rosegarden/src/gui/studio/AudioPluginManager.cpp	2012-04-13 14:54:53.073759223 -0500
@@ -37,7 +37,7 @@
 #include <tqmutex.h>
 #include <tqstring.h>
 #include <tqthread.h>
-
+#include <unistd.h>
 
 namespace Rosegarden
 {
diff -uNbr rosegarden.orig/src/gui/studio/AudioPluginOSCGUIManager.cpp rosegarden/src/gui/studio/AudioPluginOSCGUIManager.cpp
--- rosegarden.orig/src/gui/studio/AudioPluginOSCGUIManager.cpp	2012-02-08 18:36:12.000000000 -0600
+++ rosegarden/src/gui/studio/AudioPluginOSCGUIManager.cpp	2012-04-13 11:51:21.502750255 -0500
@@ -25,6 +25,7 @@
 #ifdef HAVE_LIBLO
 
 #include <lo/lo.h>
+#include <unistd.h>
 
 #include "AudioPluginOSCGUIManager.h"
 
diff -uNbr rosegarden.orig/src/sound/RingBuffer.h rosegarden/src/sound/RingBuffer.h
--- rosegarden.orig/src/sound/RingBuffer.h	2012-02-08 18:36:12.000000000 -0600
+++ rosegarden/src/sound/RingBuffer.h	2012-04-13 11:52:06.253350883 -0500
@@ -24,6 +24,7 @@
 
 #include <sys/types.h>
 #include <sys/mman.h>
+#include <string.h>
 
 #include "Scavenger.h"
 
