diff --git a/Source/Processors/FileReader/FileReader.cpp b/Source/Processors/FileReader/FileReader.cpp
index d558bd5ed5f72f6d7a325d22040c9f41600af573..bdeb3f014c73d893052b4cfa9d0e69b8421ff432 100644
--- a/Source/Processors/FileReader/FileReader.cpp
+++ b/Source/Processors/FileReader/FileReader.cpp
@@ -35,6 +35,7 @@ FileReader::FileReader()
 
     enabledState(false);
 
+    counter = 0;
 
 }
 
@@ -80,6 +81,11 @@ int FileReader::getNumHeadstageOutputs()
         return 16;
 }
 
+int FileReader::getNumEventChannels()
+{
+    return 8;
+}
+
 float FileReader::getBitVolts(Channel* chan)
 {
     if (input)
@@ -174,26 +180,10 @@ void FileReader::process(AudioSampleBuffer& buffer, MidiBuffer& events)
 
     setTimestamp(events, timestamp);
 
+    int samplesNeeded = (int) float(buffer.getNumSamples()) * (getDefaultSampleRate()/44100.0f);
     // FIXME: needs to account for the fact that the ratio might not be an exact
     //        integer value
 
-    // code for testing events:
-    // if (counter > 100)
-    // {
-    //     addEvent(events,    // MidiBuffer
-    //          TTL, // eventType
-    //          0,         // sampleNum
-    //          1,    // eventID
-    //          0      // eventChannel
-    //         );
-    //     counter = 0;
-    // } else {
-    //     counter++;
-
-    // }
-
-    int samplesNeeded = (int) float(buffer.getNumSamples()) * (getDefaultSampleRate()/44100.0f);
-
     int samplesRead = 0;
 
     while (samplesRead < samplesNeeded)
@@ -222,6 +212,33 @@ void FileReader::process(AudioSampleBuffer& buffer, MidiBuffer& events)
     timestamp += samplesNeeded;
     setNumSamples(events, samplesNeeded);
 
+    // code for testing events:
+    if (counter == 100)
+    {
+        std::cout << "Adding on event for node id: " << nodeId << std::endl;
+        addEvent(events,    // MidiBuffer
+             TTL, // eventType
+             0,         // sampleNum
+             1,    // eventID
+             1      // eventChannel
+            );
+
+        counter++;
+    } else if (counter > 120) 
+    {
+        std::cout << "Adding off event!" << std::endl;
+        addEvent(events,    // MidiBuffer
+             TTL, // eventType
+             0,         // sampleNum
+             0,    // eventID
+             1      // eventChannel
+            );
+
+        counter = 0;
+    } else {
+        counter++;
+    }
+
 }
 
 
diff --git a/Source/Processors/FileReader/FileReader.h b/Source/Processors/FileReader/FileReader.h
index 0624b511fac9196c8c9106c45359d24daca49fad..369a92ab46c02749fd556db03fcb0b35c400ff0c 100644
--- a/Source/Processors/FileReader/FileReader.h
+++ b/Source/Processors/FileReader/FileReader.h
@@ -72,6 +72,7 @@ public:
 
     float getDefaultSampleRate();
     int getNumHeadstageOutputs();
+    int getNumEventChannels();
     float getBitVolts(Channel* chan);
 
     bool setFile(String fullpath);
@@ -90,6 +91,8 @@ private:
 
     int64 currentSample;
 
+    int counter; // for testing purposes only
+
     ScopedPointer<FileSource> input;
 
     HeapBlock<int16> readBuffer;
diff --git a/Source/Processors/GenericProcessor/GenericProcessor.cpp b/Source/Processors/GenericProcessor/GenericProcessor.cpp
index 97c30f733863e9fdfb05c8c3f820cba7268b71d7..10657ddb93391217f5d7670b60085acb7b161580 100755
--- a/Source/Processors/GenericProcessor/GenericProcessor.cpp
+++ b/Source/Processors/GenericProcessor/GenericProcessor.cpp
@@ -432,6 +432,8 @@ void GenericProcessor::update()
         for (int m = 0; m < getNumEventChannels(); m++)
         {
             Channel* ch = new Channel(this, m+1, EVENT_CHANNEL);
+            ch->sourceNodeId = nodeId;
+            ch->nodeIndex = nidx;
             eventChannels.add(ch);
         }
 
@@ -671,12 +673,12 @@ int GenericProcessor::processEventBuffer(MidiBuffer& events)
 
                 if (*dataptr == TTL &&    // a TTL event
                     getNodeId() < 900 && // not handled by a specialized processor (e.g. AudioNode))
-                    *(dataptr+1) > 0)    // that's flagged for saving
+                    *(dataptr+4) > 0)    // that's flagged for saving
                 {
                     // changing the const cast is dangerous, but probably necessary:
                     uint8* ptr = const_cast<uint8*>(dataptr);
-                    *(ptr + 1) = 0; // set second byte of raw data to 0, so the event
-                    // won't be saved twice
+                    *(ptr + 4) = 0; // set fifth byte of raw data to 0, so the event
+                                    // won't be saved twice
                 }
             }
         }
@@ -724,16 +726,19 @@ void GenericProcessor::addEvent(MidiBuffer& eventBuffer,
                                 uint8 numBytes,
                                 uint8* eventData)
 {
-    uint8* data = new uint8[4+numBytes];
+    uint8* data = new uint8[5+numBytes];
 
     data[0] = type;    // event type
     data[1] = nodeId;  // processor ID automatically added
     data[2] = eventId; // event ID
     data[3] = eventChannel; // event channel
-    memcpy(data + 4, eventData, numBytes);
+    data[4] = 1; // saving flag
+    memcpy(data + 5, eventData, numBytes);
+
+    //std::cout << "Node id: " << data[1] << std::endl;
 
     eventBuffer.addEvent(data, 		// raw data
-                         4 + numBytes, // total bytes
+                         5 + numBytes, // total bytes
                          sampleNum);     // sample index
 
     //if (type == TTL)
diff --git a/Source/Processors/LfpDisplayNode/LfpDisplayCanvas.cpp b/Source/Processors/LfpDisplayNode/LfpDisplayCanvas.cpp
index 5327cb5583c467114b8a3dff633fd0bc6def1ca7..63baf568af0253883acf6c0364334d64e1160089 100755
--- a/Source/Processors/LfpDisplayNode/LfpDisplayCanvas.cpp
+++ b/Source/Processors/LfpDisplayNode/LfpDisplayCanvas.cpp
@@ -341,7 +341,7 @@ void LfpDisplayCanvas::update()
     lastScreenBufferIndex.clear();
     displayBufferIndex.clear();
 
-    for (int i = 0; i < nChans; i++)
+    for (int i = 0; i <= nChans; i++) // extra channel for events
     {
         sampleRate.add(processor->channels[i]->sampleRate);
         displayBufferIndex.add(0);
@@ -355,7 +355,7 @@ void LfpDisplayCanvas::update()
 
         refreshScreenBuffer();
 
-        lfpDisplay->setNumChannels(nChans);
+        lfpDisplay->setNumChannels(nChans); // add an extra channel for events
 
         // update channel names
         for (int i = 0; i < processor->getNumInputs(); i++)
@@ -620,7 +620,7 @@ void LfpDisplayCanvas::refreshState()
 {
     // called when the component's tab becomes visible again
 
-    for (int i = 0; i < displayBufferIndex.size(); i++)
+    for (int i = 0; i <= displayBufferIndex.size(); i++) // include event channel
     {
 
         displayBufferIndex.set(i, processor->getDisplayBufferIndex(i));
@@ -632,7 +632,7 @@ void LfpDisplayCanvas::refreshState()
 void LfpDisplayCanvas::refreshScreenBuffer()
 {
 
-    for (int i = 0; i < screenBufferIndex.size(); i++)
+    for (int i = 0; i <= screenBufferIndex.size(); i++)
         screenBufferIndex.set(i,0);
 
     screenBuffer->clear();
@@ -673,6 +673,9 @@ void LfpDisplayCanvas::updateScreenBuffer()
         int sbi = screenBufferIndex[channel];
         int dbi = displayBufferIndex[channel];
 
+        //if (channel == 16)
+         //   std::cout << sbi << " " << dbi << std::endl;
+
         lastScreenBufferIndex.set(channel,sbi);
 
         int index = processor->getDisplayBufferIndex(channel);
@@ -769,11 +772,9 @@ void LfpDisplayCanvas::updateScreenBuffer()
                     screenBufferMin->addSample(channel, sbi, sample_min*gain);
                     screenBufferMax->addSample(channel, sbi, sample_max*gain);
                 
-
                 sbi++;
                 }
             
-
             subSampleOffset += ratio;
 
             while (subSampleOffset >= 1.0)
@@ -1746,12 +1747,17 @@ void LfpChannelDisplay::paint(Graphics& g)
 
             // draw event markers
             int rawEventState = canvas->getYCoord(canvas->getNumChannels(), i);// get last channel+1 in buffer (represents events)
+            
+            //if (i == ifrom)
+            //    std::cout << rawEventState << std::endl;
+
             for (int ev_ch = 0; ev_ch < 8 ; ev_ch++) // for all event channels
             {
                 if (display->getEventDisplayState(ev_ch))  // check if plotting for this channel is enabled
                 {
                     if (rawEventState & (1 << ev_ch))    // events are  representet by a bit code, so we have to extract the individual bits with a mask
                     {
+                        std::cout << "Drawing event." << std::endl;
                         g.setColour(display->channelColours[ev_ch*2]); // get color from lfp color scheme
                         g.setOpacity(0.35f);
                         g.drawLine(i, center-channelHeight/2 , i, center+channelHeight/2);
diff --git a/Source/Processors/LfpDisplayNode/LfpDisplayNode.cpp b/Source/Processors/LfpDisplayNode/LfpDisplayNode.cpp
index 8f2939ccb0f1a15fa255c799215d88d467676506..f242d9df787b7d874b4e8dbf6ff7a04dd5ff9c1e 100755
--- a/Source/Processors/LfpDisplayNode/LfpDisplayNode.cpp
+++ b/Source/Processors/LfpDisplayNode/LfpDisplayNode.cpp
@@ -57,7 +57,7 @@ AudioProcessorEditor* LfpDisplayNode::createEditor()
 
 void LfpDisplayNode::updateSettings()
 {
-    // std::cout << "Setting num inputs on LfpDisplayNode to " << getNumInputs() << std::endl;
+    std::cout << "Setting num inputs on LfpDisplayNode to " << getNumInputs() << std::endl;
 
     channelForEventSource.clear();
     eventSourceNodes.clear();
@@ -74,8 +74,11 @@ void LfpDisplayNode::updateSettings()
 
     numEventChannels = eventSourceNodes.size();
 
+    std::cout << "Found " << numEventChannels << " event channels." << std::endl;
+
     for (int i = 0; i < eventSourceNodes.size(); i++)
     {
+        std::cout << "Adding channel " << getNumInputs() + i << " for event source node " << eventSourceNodes[i] << std::endl;
         channelForEventSource[eventSourceNodes[i]] = getNumInputs() + i;
         ttlState[eventSourceNodes[i]] = 0;
         Channel* eventChan = new Channel(this, getNumInputs() + i, EVENT_CHANNEL);
@@ -159,8 +162,9 @@ void LfpDisplayNode::handleEvent(int eventType, MidiMessage& event, int sampleNu
 
         int samplesLeft = totalSamples - eventTime;
 
-        //	std::cout << "Received event from " << eventNodeId << ", channel "
-        //	          << eventChannel << ", with ID " << eventId << std::endl;
+        	std::cout << "Received event from " << eventSourceNode << ", channel "
+        	          << eventChannel << ", with ID " << eventId << ", copying to "
+                      << channelForEventSource[eventSourceNode] << std::endl;
         //
         int bufferIndex = (displayBufferIndex[channelForEventSource[eventSourceNode]] + eventTime);// % displayBuffer->getNumSamples();
 
@@ -176,7 +180,7 @@ void LfpDisplayNode::handleEvent(int eventType, MidiMessage& event, int sampleNu
         if (samplesLeft + bufferIndex < displayBuffer->getNumSamples())
         {
 
-            //	std::cout << bufferIndex << " " << samplesLeft << " " << ttlState << std::endl;
+            std::cout << bufferIndex << " " << samplesLeft << " " << ttlState[eventSourceNode] << std::endl;
 
             displayBuffer->copyFrom(channelForEventSource[eventSourceNode],  // destChannel
                                     bufferIndex,		// destStartSample
diff --git a/Source/Processors/RecordNode/RecordNode.cpp b/Source/Processors/RecordNode/RecordNode.cpp
index 1a92b34f2a8af10f5768e8648c6449dfad397492..48b283eee7c446071bb6ee376814e92e34c51551 100755
--- a/Source/Processors/RecordNode/RecordNode.cpp
+++ b/Source/Processors/RecordNode/RecordNode.cpp
@@ -414,7 +414,7 @@ void RecordNode::handleEvent(int eventType, MidiMessage& event, int samplePositi
     {
         if ((eventType == TTL) || (eventType == MESSAGE))
         {
-            if (event.getNoteNumber() > 0) // processor ID > 0 (i.e., event has not already been processed)
+            if (event.getRawData()+4 > 0) // saving flag > 0 (i.e., event has not already been processed)
             {
                 EVERY_ENGINE->writeEvent(eventType, event, samplePosition);
             }
diff --git a/Source/Processors/SourceNode/SourceNode.cpp b/Source/Processors/SourceNode/SourceNode.cpp
index 6675ddc3e82917d3db226911a1edacb6d07bc14e..79964dc0e52bd54a28f64fbf00b772d56b4f3316 100755
--- a/Source/Processors/SourceNode/SourceNode.cpp
+++ b/Source/Processors/SourceNode/SourceNode.cpp
@@ -265,6 +265,14 @@ int SourceNode::getNumAdcOutputs()
         return 0;
 }
 
+int SourceNode::getNumEventChannels()
+{
+    if (dataThread != 0)
+        return dataThread->getNumEventChannels();
+    else
+        return 0;
+}
+
 float SourceNode::getBitVolts(Channel* chan)
 {
 	if (dataThread != 0)
diff --git a/Source/Processors/SourceNode/SourceNode.h b/Source/Processors/SourceNode/SourceNode.h
index 7095c1fd46d8227d9ba7f629592753d648aba1c8..1b2f1f18a3cf4a8622ed894fe37517019f0747e3 100755
--- a/Source/Processors/SourceNode/SourceNode.h
+++ b/Source/Processors/SourceNode/SourceNode.h
@@ -58,8 +58,11 @@ public:
     float getSampleRate();
     float getDefaultSampleRate();
     int getNumHeadstageOutputs();
+
     int getNumAuxOutputs();
     int getNumAdcOutputs();
+
+    int getNumEventChannels();
     float getBitVolts(Channel* chan);
 
     int modifyChannelGain(int stream, int channel,ChannelType type, float gain, bool updateSignalChain);