diff --git a/Source/Processors/ChannelMappingNode.cpp b/Source/Processors/ChannelMappingNode.cpp
index 4388f0879c3066987a902ef5e4a39202dba35e64..536d47bdede43795d95a3933dd9c401b06ca8fca 100644
--- a/Source/Processors/ChannelMappingNode.cpp
+++ b/Source/Processors/ChannelMappingNode.cpp
@@ -84,9 +84,7 @@ void ChannelMappingNode::process(AudioSampleBuffer& buffer,
 {
 
 	// use copy constructor to set the data to refer to
-	channelBuffer = buffer; //.setDataToReferTo(buffer.getArrayOfChannels(), 
-							//	   buffer.getNumChannels(),
-						//		   buffer.getNumSamples());
+	channelBuffer = buffer;
 
 	// copy it back into the buffer according to the channel mapping
 	buffer.clear();
diff --git a/Source/Processors/SpikeDetector.cpp b/Source/Processors/SpikeDetector.cpp
index 7ee4348b5d249bb15f5467c8f61004af599ea905..ce796f79b8d2040b7333b72d0ab270cc33666faa 100755
--- a/Source/Processors/SpikeDetector.cpp
+++ b/Source/Processors/SpikeDetector.cpp
@@ -335,7 +335,7 @@ void SpikeDetector::addSpikeEvent(SpikeObject* s, MidiBuffer& eventBuffer, int p
 
     s->eventType = SPIKE_EVENT_CODE;
 
-    int numBytes = packSpike(s, spikeBuffer, 256);
+    int numBytes = packSpike(s, spikeBuffer, MAX_SPIKE_BUFFER_LEN);
 
     eventBuffer.addEvent(spikeBuffer, numBytes, peakIndex);
 
@@ -349,10 +349,7 @@ void SpikeDetector::addWaveformToSpikeObject(SpikeObject* s,
     int spikeLength = electrodes[electrodeNumber]->prePeakSamples +
                       + electrodes[electrodeNumber]->postPeakSamples;
 
-    //uint8 dataSize = spikeLength*2;
-
-    // uint8 data[dataSize];
-    // uint8* dataptr = data;
+    s->timestamp = timestamp + peakIndex;
 
     s->nSamples = spikeLength;
 
@@ -399,6 +396,19 @@ void SpikeDetector::addWaveformToSpikeObject(SpikeObject* s,
     sampleIndex -= spikeLength; // reset sample index
 
 
+}
+
+void SpikeDetector::handleEvent(int eventType, MidiMessage& event, int sampleNum)
+{
+
+    if (eventType == TIMESTAMP)
+    {
+        const uint8* dataptr = event.getRawData();
+
+        memcpy(&timestamp, dataptr + 4, 8); // remember to skip first four bytes
+    }
+
+
 }
 
 void SpikeDetector::process(AudioSampleBuffer& buffer,
@@ -410,6 +420,8 @@ void SpikeDetector::process(AudioSampleBuffer& buffer,
     Electrode* electrode;
     dataBuffer = buffer;
 
+    checkForEvents(events);
+
     //std::cout << dataBuffer.getMagnitude(0,nSamples) << std::endl;
 
     for (int i = 0; i < electrodes.size(); i++)
diff --git a/Source/Processors/SpikeDetector.h b/Source/Processors/SpikeDetector.h
index 11e84960eb82f975733dd1b597f696f22b8b70f3..8c820b985ce0c8cdb0b7ef1092174cccea2adfa9 100755
--- a/Source/Processors/SpikeDetector.h
+++ b/Source/Processors/SpikeDetector.h
@@ -167,6 +167,7 @@ private:
     };
 
     uint8_t* spikeBuffer;///[256];
+    uint64_t timestamp;
 
     Array<Electrode*> electrodes;
 
@@ -175,6 +176,8 @@ private:
     // 					  int& currentChannel,
     // 					  MidiBuffer& eventBuffer);
 
+    void handleEvent(int eventType, MidiMessage& event, int sampleNum);
+
     void addSpikeEvent(SpikeObject* s, MidiBuffer& eventBuffer, int peakIndex);
     void addWaveformToSpikeObject(SpikeObject* s,
                                   int& peakIndex,
diff --git a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp
index cf904d76971b00497d37da260b8c413dfe337bcd..60281b853c116bbba864069f0080a543b77305cb 100755
--- a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp
+++ b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp
@@ -540,9 +540,9 @@ void SpikePlot::writeSpike(const SpikeObject& s)
 {
 
 
-    packSpike(&s, spikeBuffer, 256);
+    packSpike(&s, spikeBuffer, MAX_SPIKE_BUFFER_LEN);
 
-    fwrite(spikeBuffer, 1, 256, file);
+    fwrite(spikeBuffer, 1, MAX_SPIKE_BUFFER_LEN, file);
 
 
 }
@@ -565,7 +565,9 @@ String SpikePlot::generateHeader()
     header += name;
     header += "';\n";
 
-    header += "header.channelType = 'Electrode';\n";
+    header += "header.num_channels = ";
+    header += nChannels; 
+    header += ";\n";
 
     header = header.paddedRight(' ', HEADER_SIZE);