diff --git a/.gitignore b/.gitignore
index 81ca2bed613de3acc078f9ab9e37d6630f072a0d..8961ce21f170309bae02d0b72ada31aa5ec7235a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -64,6 +64,8 @@ cscope.files
 cscope.out
 *~
 .dir-locals.el
+*.swp
+gmon.out
 
 # 7. Open Ephys data files
 *.continuous
diff --git a/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj b/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj
index bf9b5a4be6b1b36a74bc43f58f81f08293764b3a..649e1c0d63d02bd14305890f6082cbf3e3429654 100644
--- a/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj
+++ b/Builds/MacOSX/open-ephys.xcodeproj/project.pbxproj
@@ -3790,6 +3790,7 @@
 				INFOPLIST_FILE = Info.plist;
 				INSTALL_PATH = "$(HOME)/Applications";
 				MACOSX_DEPLOYMENT_TARGET_ppc = 10.4;
+				ONLY_ACTIVE_ARCH = YES;
 				OTHER_LDFLAGS = (
 					"-lhdf5",
 					"-lhdf5_cpp",
@@ -3813,13 +3814,7 @@
 				GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
 				GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
-				HEADER_SEARCH_PATHS = (
-					"$(inherited)",
-					/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
-					/usr/local/hdf5/include,
-				);
-				LIBRARY_SEARCH_PATHS = /usr/local/hdf5/lib;
-				ONLY_ACTIVE_ARCH = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.8;
 				PRODUCT_NAME = "open-ephys";
 				SDKROOT = macosx10.8;
 				WARNING_CFLAGS = "-Wreorder";
diff --git a/Builds/VisualStudio2012/open-ephys.sln b/Builds/VisualStudio2012/open-ephys.sln
index 61074c0e04aebb4f1d48dd95b47ccd0a86ed9f09..520a8d855d09a997cfccb769049bb0e4c270ef34 100644
--- a/Builds/VisualStudio2012/open-ephys.sln
+++ b/Builds/VisualStudio2012/open-ephys.sln
@@ -1,21 +1,29 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
+Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio 2012
-Project("{5A05F353-1D63-394C-DFB0-981BB2309002}") = "open-ephys", "open-ephys.vcxproj", "{9C924D66-7DEC-1AEF-B375-DB8666BFB909}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "open-ephys", "open-ephys.vcxproj", "{9C924D66-7DEC-1AEF-B375-DB8666BFB909}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
+		Debug|x64 = Debug|x64
+		Debug64|Win32 = Debug64|Win32
 		Debug64|x64 = Debug64|x64
+		Release|Win32 = Release|Win32
+		Release|x64 = Release|x64
+		Release64|Win32 = Release64|Win32
 		Release64|x64 = Release64|x64
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Debug|Win32.ActiveCfg = Debug|Win32
 		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Debug|Win32.Build.0 = Debug|Win32
-		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Release|Win32.ActiveCfg = Release|Win32
-		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Release|Win32.Build.0 = Release|Win32
+		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Debug|x64.ActiveCfg = Debug|Win32
+		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Debug64|Win32.ActiveCfg = Debug64|x64
 		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Debug64|x64.ActiveCfg = Debug64|x64
 		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Debug64|x64.Build.0 = Debug64|x64
+		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Release|Win32.ActiveCfg = Release|Win32
+		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Release|Win32.Build.0 = Release|Win32
+		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Release|x64.ActiveCfg = Release|Win32
+		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Release64|Win32.ActiveCfg = Release64|x64
 		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Release64|x64.ActiveCfg = Release64|x64
 		{9C924D66-7DEC-1AEF-B375-DB8666BFB909}.Release64|x64.Build.0 = Release64|x64
 	EndGlobalSection
diff --git a/Resources/Configs/Intan2132_16chx1_map_reordered.xml b/Resources/Configs/Intan2132_16chx1_map_reordered.xml
new file mode 100644
index 0000000000000000000000000000000000000000..0a4cef74785f0bbebf59b1ba85319d2c87cbf63f
--- /dev/null
+++ b/Resources/Configs/Intan2132_16chx1_map_reordered.xml
@@ -0,0 +1,328 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<SETTINGS>
+  <INFO>
+    <VERSION>0.2.7</VERSION>
+    <DATE>12 Aug 2014 9:16:28</DATE>
+    <OS>Windows 7</OS>
+    <MACHINE>IBS_8515</MACHINE>
+  </INFO>
+  <SIGNALCHAIN>
+    <PROCESSOR name="Sources/Rhythm FPGA" insertionPoint="1" NodeId="100">
+      <CHANNEL name="0" number="0">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="1" number="1">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="2" number="2">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="3" number="3">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="4" number="4">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="5" number="5">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="6" number="6">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="7" number="7">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="8" number="8">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="9" number="9">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="10" number="10">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="11" number="11">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="12" number="12">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="13" number="13">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="14" number="14">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="15" number="15">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="16" number="16">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="17" number="17">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="18" number="18">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="19" number="19">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="20" number="20">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="21" number="21">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="22" number="22">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="23" number="23">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="24" number="24">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="25" number="25">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="26" number="26">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="27" number="27">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="28" number="28">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="29" number="29">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="30" number="30">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="31" number="31">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="32" number="32">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="33" number="33">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="34" number="34">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <EVENTCHANNEL name="0" number="0"/>
+      <EVENTCHANNEL name="1" number="1"/>
+      <EVENTCHANNEL name="2" number="2"/>
+      <EVENTCHANNEL name="3" number="3"/>
+      <EVENTCHANNEL name="4" number="4"/>
+      <EVENTCHANNEL name="5" number="5"/>
+      <EVENTCHANNEL name="6" number="6"/>
+      <EVENTCHANNEL name="7" number="7"/>
+      <EVENTCHANNEL name="8" number="8"/>
+      <EVENTCHANNEL name="9" number="9"/>
+      <EVENTCHANNEL name="10" number="10"/>
+      <EVENTCHANNEL name="11" number="11"/>
+      <EVENTCHANNEL name="12" number="12"/>
+      <EVENTCHANNEL name="13" number="13"/>
+      <EVENTCHANNEL name="14" number="14"/>
+      <EVENTCHANNEL name="15" number="15"/>
+      <EDITOR isCollapsed="0" displayName="Rhythm FPGA" SampleRate="17" LowCut="1.32177484"
+              HighCut="7603.76512" ADCsOn="0"/>
+    </PROCESSOR>
+    <PROCESSOR name="Filters/Channel Map" insertionPoint="1" NodeId="101">
+      <CHANNEL name="0" number="0">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="1" number="1">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="2" number="2">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="3" number="3">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="4" number="4">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="5" number="5">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="6" number="6">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="7" number="7">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="8" number="8">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="9" number="9">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="10" number="10">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="11" number="11">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="12" number="12">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="13" number="13">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="14" number="14">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="15" number="15">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <EVENTCHANNEL name="0" number="0"/>
+      <EVENTCHANNEL name="1" number="1"/>
+      <EVENTCHANNEL name="2" number="2"/>
+      <EVENTCHANNEL name="3" number="3"/>
+      <EVENTCHANNEL name="4" number="4"/>
+      <EVENTCHANNEL name="5" number="5"/>
+      <EVENTCHANNEL name="6" number="6"/>
+      <EVENTCHANNEL name="7" number="7"/>
+      <EVENTCHANNEL name="8" number="8"/>
+      <EVENTCHANNEL name="9" number="9"/>
+      <EVENTCHANNEL name="10" number="10"/>
+      <EVENTCHANNEL name="11" number="11"/>
+      <EVENTCHANNEL name="12" number="12"/>
+      <EVENTCHANNEL name="13" number="13"/>
+      <EVENTCHANNEL name="14" number="14"/>
+      <EVENTCHANNEL name="15" number="15"/>
+      <EDITOR isCollapsed="0" displayName="Channel Map" Type="ChannelMappingEditor">
+        <SETTING Type="visibleChannels" Value="35"/>
+        <CHANNEL Number="0" Mapping="1" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="1" Mapping="2" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="2" Mapping="3" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="3" Mapping="4" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="4" Mapping="5" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="5" Mapping="6" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="6" Mapping="7" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="7" Mapping="8" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="8" Mapping="21" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="9" Mapping="22" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="10" Mapping="23" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="11" Mapping="24" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="12" Mapping="9" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="13" Mapping="10" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="14" Mapping="11" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="15" Mapping="12" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="16" Mapping="13" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="17" Mapping="14" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="18" Mapping="15" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="19" Mapping="16" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="20" Mapping="17" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="21" Mapping="18" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="22" Mapping="19" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="23" Mapping="20" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="24" Mapping="25" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="25" Mapping="26" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="26" Mapping="27" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="27" Mapping="28" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="28" Mapping="29" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="29" Mapping="30" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="30" Mapping="31" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="31" Mapping="32" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="32" Mapping="33" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="33" Mapping="34" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="34" Mapping="35" Reference="-1" Enabled="0"/>
+        <REFERENCE Number="0" Channel="-2"/>
+        <REFERENCE Number="1" Channel="-1"/>
+        <REFERENCE Number="2" Channel="-1"/>
+        <REFERENCE Number="3" Channel="-1"/>
+      </EDITOR>
+    </PROCESSOR>
+    <PROCESSOR name="Sinks/LFP Viewer" insertionPoint="1" NodeId="102">
+      <CHANNEL name="0" number="0">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="1" number="1">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="2" number="2">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="3" number="3">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="4" number="4">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="5" number="5">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="6" number="6">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="7" number="7">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="8" number="8">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="9" number="9">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="10" number="10">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="11" number="11">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="12" number="12">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="13" number="13">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="14" number="14">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="15" number="15">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <EVENTCHANNEL name="0" number="0"/>
+      <EVENTCHANNEL name="1" number="1"/>
+      <EVENTCHANNEL name="2" number="2"/>
+      <EVENTCHANNEL name="3" number="3"/>
+      <EVENTCHANNEL name="4" number="4"/>
+      <EVENTCHANNEL name="5" number="5"/>
+      <EVENTCHANNEL name="6" number="6"/>
+      <EVENTCHANNEL name="7" number="7"/>
+      <EVENTCHANNEL name="8" number="8"/>
+      <EVENTCHANNEL name="9" number="9"/>
+      <EVENTCHANNEL name="10" number="10"/>
+      <EVENTCHANNEL name="11" number="11"/>
+      <EVENTCHANNEL name="12" number="12"/>
+      <EVENTCHANNEL name="13" number="13"/>
+      <EVENTCHANNEL name="14" number="14"/>
+      <EVENTCHANNEL name="15" number="15"/>
+      <EDITOR isCollapsed="0" displayName="LFP Viewer" Type="Visualizer">
+        <TAB Active="1"/>
+        <WINDOW Active="0"/>
+        <LFPDISPLAY Range="4" Timebase="2" Spread="5" colorGrouping="1" EventButtonState="255"
+                    ChannelDisplayState="1111111111111111" ScrollX="0" ScrollY="0"/>
+      </EDITOR>
+    </PROCESSOR>
+  </SIGNALCHAIN>
+  <AUDIO bufferSize="1024"/>
+  <CONTROLPANEL isOpen="0" prependText="" appendText=""/>
+  <AUDIOEDITOR isMuted="0" volume="0" noiseGate="0"/>
+  <PROCESSORLIST>
+    <COLOR ID="801" R="59" G="59" B="59"/>
+    <COLOR ID="804" R="241" G="90" B="41"/>
+    <COLOR ID="802" R="0" G="174" B="239"/>
+    <COLOR ID="803" R="0" G="166" B="81"/>
+    <COLOR ID="805" R="147" G="149" B="152"/>
+  </PROCESSORLIST>
+  <UICOMPONENT isProcessorListOpen="1" isEditorViewportOpen="1"/>
+</SETTINGS>
diff --git a/Resources/Configs/Intan2132_16chx2_map_reordered.xml b/Resources/Configs/Intan2132_16chx2_map_reordered.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5589a48f6c4ab6a7da093e3450edb24666a07692
--- /dev/null
+++ b/Resources/Configs/Intan2132_16chx2_map_reordered.xml
@@ -0,0 +1,565 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<SETTINGS>
+  <INFO>
+    <VERSION>0.2.7</VERSION>
+    <DATE>12 Aug 2014 9:15:23</DATE>
+    <OS>Windows 7</OS>
+    <MACHINE>IBS_8515</MACHINE>
+  </INFO>
+  <SIGNALCHAIN>
+    <PROCESSOR name="Sources/Rhythm FPGA" insertionPoint="1" NodeId="100">
+      <CHANNEL name="0" number="0">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="1" number="1">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="2" number="2">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="3" number="3">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="4" number="4">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="5" number="5">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="6" number="6">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="7" number="7">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="8" number="8">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="9" number="9">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="10" number="10">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="11" number="11">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="12" number="12">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="13" number="13">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="14" number="14">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="15" number="15">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="16" number="16">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="17" number="17">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="18" number="18">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="19" number="19">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="20" number="20">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="21" number="21">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="22" number="22">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="23" number="23">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="24" number="24">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="25" number="25">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="26" number="26">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="27" number="27">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="28" number="28">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="29" number="29">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="30" number="30">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="31" number="31">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="32" number="32">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="33" number="33">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="34" number="34">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="35" number="35">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="36" number="36">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="37" number="37">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="38" number="38">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="39" number="39">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="40" number="40">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="41" number="41">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="42" number="42">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="43" number="43">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="44" number="44">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="45" number="45">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="46" number="46">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="47" number="47">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="48" number="48">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="49" number="49">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="50" number="50">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="51" number="51">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="52" number="52">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="53" number="53">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="54" number="54">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="55" number="55">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="56" number="56">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="57" number="57">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="58" number="58">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="59" number="59">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="60" number="60">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="61" number="61">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="62" number="62">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="63" number="63">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="64" number="64">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="65" number="65">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="66" number="66">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="67" number="67">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="68" number="68">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="69" number="69">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <EVENTCHANNEL name="0" number="0"/>
+      <EVENTCHANNEL name="1" number="1"/>
+      <EVENTCHANNEL name="2" number="2"/>
+      <EVENTCHANNEL name="3" number="3"/>
+      <EVENTCHANNEL name="4" number="4"/>
+      <EVENTCHANNEL name="5" number="5"/>
+      <EVENTCHANNEL name="6" number="6"/>
+      <EVENTCHANNEL name="7" number="7"/>
+      <EVENTCHANNEL name="8" number="8"/>
+      <EVENTCHANNEL name="9" number="9"/>
+      <EVENTCHANNEL name="10" number="10"/>
+      <EVENTCHANNEL name="11" number="11"/>
+      <EVENTCHANNEL name="12" number="12"/>
+      <EVENTCHANNEL name="13" number="13"/>
+      <EVENTCHANNEL name="14" number="14"/>
+      <EVENTCHANNEL name="15" number="15"/>
+      <EDITOR isCollapsed="0" displayName="Rhythm FPGA" SampleRate="17" LowCut="1.20484568"
+              HighCut="7603.76512" ADCsOn="0"/>
+    </PROCESSOR>
+    <PROCESSOR name="Filters/Channel Map" insertionPoint="1" NodeId="101">
+      <CHANNEL name="0" number="0">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="1" number="1">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="2" number="2">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="3" number="3">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="4" number="4">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="5" number="5">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="6" number="6">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="7" number="7">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="8" number="8">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="9" number="9">
+        <SELECTIONSTATE param="0" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="10" number="10">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="11" number="11">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="12" number="12">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="13" number="13">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="14" number="14">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="15" number="15">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="16" number="16">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="17" number="17">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="18" number="18">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="19" number="19">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="20" number="20">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="21" number="21">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="22" number="22">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="23" number="23">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="24" number="24">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="25" number="25">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="26" number="26">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="27" number="27">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="28" number="28">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="29" number="29">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="30" number="30">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="31" number="31">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <EVENTCHANNEL name="0" number="0"/>
+      <EVENTCHANNEL name="1" number="1"/>
+      <EVENTCHANNEL name="2" number="2"/>
+      <EVENTCHANNEL name="3" number="3"/>
+      <EVENTCHANNEL name="4" number="4"/>
+      <EVENTCHANNEL name="5" number="5"/>
+      <EVENTCHANNEL name="6" number="6"/>
+      <EVENTCHANNEL name="7" number="7"/>
+      <EVENTCHANNEL name="8" number="8"/>
+      <EVENTCHANNEL name="9" number="9"/>
+      <EVENTCHANNEL name="10" number="10"/>
+      <EVENTCHANNEL name="11" number="11"/>
+      <EVENTCHANNEL name="12" number="12"/>
+      <EVENTCHANNEL name="13" number="13"/>
+      <EVENTCHANNEL name="14" number="14"/>
+      <EVENTCHANNEL name="15" number="15"/>
+      <EDITOR isCollapsed="0" displayName="Channel Map" Type="ChannelMappingEditor">
+        <SETTING Type="visibleChannels" Value="70"/>
+        <CHANNEL Number="0" Mapping="1" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="1" Mapping="2" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="2" Mapping="3" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="3" Mapping="4" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="4" Mapping="5" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="5" Mapping="6" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="6" Mapping="7" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="7" Mapping="8" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="8" Mapping="21" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="9" Mapping="22" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="10" Mapping="23" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="11" Mapping="24" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="12" Mapping="9" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="13" Mapping="10" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="14" Mapping="11" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="15" Mapping="12" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="16" Mapping="13" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="17" Mapping="14" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="18" Mapping="15" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="19" Mapping="16" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="20" Mapping="18" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="21" Mapping="17" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="22" Mapping="19" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="23" Mapping="20" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="24" Mapping="25" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="25" Mapping="26" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="26" Mapping="27" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="27" Mapping="28" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="28" Mapping="29" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="29" Mapping="30" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="30" Mapping="31" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="31" Mapping="32" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="32" Mapping="33" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="33" Mapping="34" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="34" Mapping="35" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="35" Mapping="36" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="36" Mapping="37" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="37" Mapping="38" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="38" Mapping="39" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="39" Mapping="40" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="40" Mapping="53" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="41" Mapping="54" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="42" Mapping="55" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="43" Mapping="56" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="44" Mapping="41" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="45" Mapping="42" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="46" Mapping="43" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="47" Mapping="44" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="48" Mapping="45" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="49" Mapping="46" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="50" Mapping="47" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="51" Mapping="48" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="52" Mapping="49" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="53" Mapping="50" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="54" Mapping="51" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="55" Mapping="52" Reference="-1" Enabled="1"/>
+        <CHANNEL Number="56" Mapping="57" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="57" Mapping="58" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="58" Mapping="59" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="59" Mapping="60" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="60" Mapping="61" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="61" Mapping="62" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="62" Mapping="63" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="63" Mapping="64" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="64" Mapping="65" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="65" Mapping="66" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="66" Mapping="67" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="67" Mapping="68" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="68" Mapping="69" Reference="-1" Enabled="0"/>
+        <CHANNEL Number="69" Mapping="70" Reference="-1" Enabled="0"/>
+        <REFERENCE Number="0" Channel="-1"/>
+        <REFERENCE Number="1" Channel="-1"/>
+        <REFERENCE Number="2" Channel="-1"/>
+        <REFERENCE Number="3" Channel="-1"/>
+      </EDITOR>
+    </PROCESSOR>
+    <PROCESSOR name="Sinks/LFP Viewer" insertionPoint="1" NodeId="102">
+      <CHANNEL name="0" number="0">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="1" number="1">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="2" number="2">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="3" number="3">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="4" number="4">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="5" number="5">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="6" number="6">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="7" number="7">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="8" number="8">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="9" number="9">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="10" number="10">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="11" number="11">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="12" number="12">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="13" number="13">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="14" number="14">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="15" number="15">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="16" number="16">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="17" number="17">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="18" number="18">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="19" number="19">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="20" number="20">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="21" number="21">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="22" number="22">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="23" number="23">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="24" number="24">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="25" number="25">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="26" number="26">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="27" number="27">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="28" number="28">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="29" number="29">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="30" number="30">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <CHANNEL name="31" number="31">
+        <SELECTIONSTATE param="1" record="0" audio="0"/>
+      </CHANNEL>
+      <EVENTCHANNEL name="0" number="0"/>
+      <EVENTCHANNEL name="1" number="1"/>
+      <EVENTCHANNEL name="2" number="2"/>
+      <EVENTCHANNEL name="3" number="3"/>
+      <EVENTCHANNEL name="4" number="4"/>
+      <EVENTCHANNEL name="5" number="5"/>
+      <EVENTCHANNEL name="6" number="6"/>
+      <EVENTCHANNEL name="7" number="7"/>
+      <EVENTCHANNEL name="8" number="8"/>
+      <EVENTCHANNEL name="9" number="9"/>
+      <EVENTCHANNEL name="10" number="10"/>
+      <EVENTCHANNEL name="11" number="11"/>
+      <EVENTCHANNEL name="12" number="12"/>
+      <EVENTCHANNEL name="13" number="13"/>
+      <EVENTCHANNEL name="14" number="14"/>
+      <EVENTCHANNEL name="15" number="15"/>
+      <EDITOR isCollapsed="0" displayName="LFP Viewer" Type="Visualizer">
+        <TAB Active="1"/>
+        <WINDOW Active="0"/>
+        <LFPDISPLAY Range="4" Timebase="2" Spread="5" colorGrouping="1" EventButtonState="255"
+                    ChannelDisplayState="11111111111111111111111111111111" ScrollX="0"
+                    ScrollY="0"/>
+      </EDITOR>
+    </PROCESSOR>
+  </SIGNALCHAIN>
+  <AUDIO bufferSize="1024"/>
+  <CONTROLPANEL isOpen="0" prependText="" appendText=""/>
+  <AUDIOEDITOR isMuted="0" volume="0" noiseGate="0"/>
+  <PROCESSORLIST>
+    <COLOR ID="801" R="59" G="59" B="59"/>
+    <COLOR ID="804" R="241" G="90" B="41"/>
+    <COLOR ID="802" R="0" G="174" B="239"/>
+    <COLOR ID="803" R="0" G="166" B="81"/>
+    <COLOR ID="805" R="147" G="149" B="152"/>
+  </PROCESSORLIST>
+  <UICOMPONENT isProcessorListOpen="1" isEditorViewportOpen="1"/>
+</SETTINGS>
diff --git a/Source/AccessClass.h b/Source/AccessClass.h
index d575c18662dd6b1f6864f843c885da012cdbf138..303150e1a83a4f3b055ede8b190cab2cb8968058 100644
--- a/Source/AccessClass.h
+++ b/Source/AccessClass.h
@@ -118,7 +118,7 @@ public:
     {
         return ac;
     }
-    
+
     /** Returns a pointer to the application's GraphViewer. */
     GraphViewer* getGraphViewer()
     {
diff --git a/Source/Audio/AudioComponent.cpp b/Source/Audio/AudioComponent.cpp
index 7d4017a25cea5277a967b21e66ea20a09b3704c5..ddfc55594edb078f186ab940e9431c0cb2d62fb0 100644
--- a/Source/Audio/AudioComponent.cpp
+++ b/Source/Audio/AudioComponent.cpp
@@ -128,7 +128,9 @@ void AudioComponent::setBufferSize(int s)
     {
         setup.bufferSize = s;
         deviceManager.setAudioDeviceSetup(setup, false);
-    } else {
+    }
+    else
+    {
         std::cout << "Buffer size out of range." << std::endl;
     }
 
@@ -146,7 +148,7 @@ int AudioComponent::getBufferSizeMs()
 {
     AudioDeviceManager::AudioDeviceSetup setup;
     deviceManager.getAudioDeviceSetup(setup);
-    
+
     return int(float(setup.bufferSize)/setup.sampleRate*1000);
 }
 
@@ -186,89 +188,91 @@ void AudioComponent::beginCallbacks()
 
     if (!isPlaying)
     {
-    
-    //const MessageManagerLock mmLock;
-    // MessageManagerLock mml (Thread::getCurrentThread());
-    
-    // if (mml.lockWasGained())
-    // {
-    //     std::cout << "AUDIO COMPONENT GOT THAT LOCK!" << std::endl;
-    // } else {
-    //     std::cout << "AUDIO COMPONENT COULDN'T GET THE LOCK...RETURNING." << std::endl;
-    //     return;
-    // }
-        
-    //     MessageManager* mm = MessageManager::getInstance();
-        
-    //     if (mm->isThisTheMessageThread())
-    //         std::cout << "THIS IS THE MESSAGE THREAD -- AUDIO COMPONENT" << std::endl;
-    //     else
-    //         std::cout << "NOT THE MESSAGE THREAD -- AUDIO COMPONENT" << std::endl;
-        
-    
-    
-    restartDevice();
-    
+
+        //const MessageManagerLock mmLock;
+        // MessageManagerLock mml (Thread::getCurrentThread());
+
+        // if (mml.lockWasGained())
+        // {
+        //     std::cout << "AUDIO COMPONENT GOT THAT LOCK!" << std::endl;
+        // } else {
+        //     std::cout << "AUDIO COMPONENT COULDN'T GET THE LOCK...RETURNING." << std::endl;
+        //     return;
+        // }
+
+        //     MessageManager* mm = MessageManager::getInstance();
+
+        //     if (mm->isThisTheMessageThread())
+        //         std::cout << "THIS IS THE MESSAGE THREAD -- AUDIO COMPONENT" << std::endl;
+        //     else
+        //         std::cout << "NOT THE MESSAGE THREAD -- AUDIO COMPONENT" << std::endl;
+
+
+
+        restartDevice();
+
         int64 ms = Time::getCurrentTime().toMilliseconds();
-        
-        while(Time::getCurrentTime().toMilliseconds() - ms < 100)
+
+        while (Time::getCurrentTime().toMilliseconds() - ms < 100)
         {
             // pause to let things finish up
-            
+
         }
 
 
-    std::cout << std::endl << "Adding audio callback." << std::endl;
-    deviceManager.addAudioCallback(graphPlayer);
-    isPlaying = true;
-    } else {
+        std::cout << std::endl << "Adding audio callback." << std::endl;
+        deviceManager.addAudioCallback(graphPlayer);
+        isPlaying = true;
+    }
+    else
+    {
         std::cout << "beginCallbacks was called while acquisition was active." << std::endl;
     }
-    
+
     //int64 ms = Time::getCurrentTime().toMilliseconds();
-    
+
     //while(Time::getCurrentTime().toMilliseconds() - ms < 100)
     //{
-        // pause to let things finish up
-        
-   // }
+    // pause to let things finish up
+
+    // }
 
 }
 
 void AudioComponent::endCallbacks()
 {
-    
-   // const MessageManagerLock mmLock; // add a lock to prevent crashes
-    
+
+    // const MessageManagerLock mmLock; // add a lock to prevent crashes
+
     // MessageManagerLock mml (Thread::getCurrentThread());
-    
+
     // if (mml.lockWasGained())
     // {
     //     std::cout << "AUDIO COMPONENT GOT THAT LOCK!" << std::endl;
     // }
 
     // MessageManager* mm = MessageManager::getInstance();
-    
+
     // if (mm->isThisTheMessageThread())
     //     std::cout << "THIS IS THE MESSAGE THREAD -- AUDIO COMPONENT" << std::endl;
     // else
     //     std::cout << "NOT THE MESSAGE THREAD -- AUDIO COMPONENT" << std::endl;
-    
-    
+
+
     std::cout << std::endl << "Removing audio callback." << std::endl;
     deviceManager.removeAudioCallback(graphPlayer);
     isPlaying = false;
 
     stopDevice();
-    
+
     int64 ms = Time::getCurrentTime().toMilliseconds();
-    
-    while(Time::getCurrentTime().toMilliseconds() - ms < 50)
+
+    while (Time::getCurrentTime().toMilliseconds() - ms < 50)
     {
         // pause to let things finish up
-        
+
     }
-    
+
 
 }
 
diff --git a/Source/Audio/AudioComponent.h b/Source/Audio/AudioComponent.h
index 8abd78cc4d8ba3cc9fde48545ba6370b9cbc3362..a77e5beaef83bc2626f7d96f12330a51161496d3 100644
--- a/Source/Audio/AudioComponent.h
+++ b/Source/Audio/AudioComponent.h
@@ -78,7 +78,7 @@ public:
 
     /** Returns the buffer size (in samples) currently being used.*/
     int getBufferSize();
-    
+
     /** Returns the buffer size (in ms) currently being used.*/
     int getBufferSizeMs();
 
diff --git a/Source/Main.cpp b/Source/Main.cpp
index cf0de5c16597addc466a234d2873c70c8dace77f..33278c084ef31a25f14c8e7089cdd92932f00f6c 100644
--- a/Source/Main.cpp
+++ b/Source/Main.cpp
@@ -29,6 +29,7 @@
 #include "UI/CustomLookAndFeel.h"
 
 #include <stdio.h>
+#include <fstream>
 
 //------------------------------------------------------------------
 
@@ -70,6 +71,9 @@ public:
             {
                 freopen("CONOUT$","w",stdout);
 				freopen("CONOUT$","w",stderr);
+                console_out = std::ofstream("CONOUT$");
+                std::cout.rdbuf(console_out.rdbuf());
+				std::cerr.rdbuf(console_out.rdbuf());
                 SetConsoleTitle("Debug Console");
 				std::cout << "Debug console..." << std::endl;
             }
@@ -115,6 +119,7 @@ public:
 private:
     ScopedPointer <MainWindow> mainWindow;
     ScopedPointer <CustomLookAndFeel> customLookAndFeel;
+    std::ofstream console_out;
 };
 
 //==============================================================================
diff --git a/Source/MainWindow.cpp b/Source/MainWindow.cpp
index 23f83eff03216789f195e2e818908a3d49c108d8..39d723b5c2b8f115a13cb5a21cdf7facb4070552 100644
--- a/Source/MainWindow.cpp
+++ b/Source/MainWindow.cpp
@@ -73,10 +73,10 @@ MainWindow::MainWindow()
     loadWindowBounds();
     setUsingNativeTitleBar(true);
     Component::addToDesktop(getDesktopWindowStyleFlags());  // prevents the maximize
-                                                            // button from randomly disappearing
+    // button from randomly disappearing
     setVisible(true);
 
-     // Constraining the window's size doesn't seem to work:
+    // Constraining the window's size doesn't seem to work:
     setResizeLimits(300, 200, 10000, 10000);
 
     if (shouldReloadOnStartup)
@@ -87,8 +87,8 @@ MainWindow::MainWindow()
 
         ui->getEditorViewport()->loadState(file);
     }
-        
-    
+
+
 
 }
 
@@ -128,7 +128,7 @@ void MainWindow::closeButtonPressed()
         audioComponent->endCallbacks();
     }
 
-	processorGraph->disableProcessors();
+    processorGraph->disableProcessors();
 
     JUCEApplication::getInstance()->systemRequestedQuit();
 
@@ -218,29 +218,30 @@ void MainWindow::loadWindowBounds()
             if (e->hasTagName("BOUNDS"))
             {
 
-            int x = e->getIntAttribute("x");
-            int y = e->getIntAttribute("y");
-            int w = e->getIntAttribute("w");
-            int h = e->getIntAttribute("h");
+                int x = e->getIntAttribute("x");
+                int y = e->getIntAttribute("y");
+                int w = e->getIntAttribute("w");
+                int h = e->getIntAttribute("h");
 
-            // bool fs = e->getBoolAttribute("fullscreen");
+                // bool fs = e->getBoolAttribute("fullscreen");
 
-            // without the correction, you get drift over time
+                // without the correction, you get drift over time
 #ifdef WIN32
-            setTopLeftPosition(x,y); //Windows doesn't need correction
+                setTopLeftPosition(x,y); //Windows doesn't need correction
 #else
-            setTopLeftPosition(x,y-27);
+                setTopLeftPosition(x,y-27);
 #endif
-            getContentComponent()->setBounds(0,0,w-10,h-33);
-            //setFullScreen(fs);
-            } else if (e->hasTagName("RECENTDIRECTORYNAMES"))
+                getContentComponent()->setBounds(0,0,w-10,h-33);
+                //setFullScreen(fs);
+            }
+            else if (e->hasTagName("RECENTDIRECTORYNAMES"))
             {
 
                 StringArray filenames;
 
                 forEachXmlChildElement(*e, directory)
                 {
-                
+
                     if (directory->hasTagName("DIRECTORY"))
                     {
                         filenames.add(directory->getStringAttribute("name"));
diff --git a/Source/Processors/AudioNode.cpp b/Source/Processors/AudioNode.cpp
index 893abeaf3def6c6384bd743879e17f4df3a2bbc4..bfd9c8ca986e1eeda036d40dbfd7918bd4f0290b 100755
--- a/Source/Processors/AudioNode.cpp
+++ b/Source/Processors/AudioNode.cpp
@@ -27,8 +27,8 @@
 
 AudioNode::AudioNode()
     : GenericProcessor("Audio Node"), audioEditor(0), volume(0.00001f), noiseGateLevel(0.0f),
-    bufferA(2,10000),
-    bufferB(2,10000)
+      bufferA(2,10000),
+      bufferB(2,10000)
 {
 
     settings.numInputs = 2048;
@@ -80,7 +80,7 @@ void AudioNode::updateBufferSize()
 {
     //AudioEditor* editor = (AudioEditor*) getEditor();
     audioEditor->updateBufferSizeText();
-    
+
 }
 
 void AudioNode::setChannel(Channel* ch)
@@ -141,7 +141,7 @@ void AudioNode::setParameter(int parameterIndex, float newValue)
     {
         // noiseGateLevel level
         noiseGateLevel = newValue; // in microVolts
-        
+
     }
     else if (parameterIndex == 100)
     {
@@ -161,11 +161,11 @@ void AudioNode::prepareToPlay(double sampleRate_, int estimatedSamplesPerBlock)
 {
 
 
-   // std::cout << "Processor sample rate: " << getSampleRate() << std::endl;
-   // std::cout << "Audio card sample rate: " << sampleRate_ << std::endl;
-   // std::cout << "Samples per block: " << estimatedSamplesPerBlock << std::endl;
+    // std::cout << "Processor sample rate: " << getSampleRate() << std::endl;
+    // std::cout << "Audio card sample rate: " << sampleRate_ << std::endl;
+    // std::cout << "Samples per block: " << estimatedSamplesPerBlock << std::endl;
 
-    numSamplesExpected = (int) (getSampleRate()/sampleRate_*float(estimatedSamplesPerBlock)) + 1; 
+    numSamplesExpected = (int)(getSampleRate()/sampleRate_*float(estimatedSamplesPerBlock)) + 1;
     // processor sample rate divided by sound card sample rate
 
     samplesInBackupBuffer = 0;
@@ -198,14 +198,16 @@ void AudioNode::process(AudioSampleBuffer& buffer,
             overflowBuffer = &bufferA;
             backupBuffer = &bufferB;
             bufferSwap = true;
-        } else {
+        }
+        else
+        {
             overflowBuffer = &bufferB;
             backupBuffer = &bufferA;
             bufferSwap = false;
         }
 
         backupBuffer->clear();
-        
+
         samplesInOverflowBuffer = samplesInBackupBuffer; // size of buffer after last round
         samplesInBackupBuffer = 0;
 
@@ -226,61 +228,61 @@ void AudioNode::process(AudioSampleBuffer& buffer,
                     {
                         // 1. copy overflow buffer
 
-                        samplesToCopy = ((samplesInOverflowBuffer <= numSamplesExpected) ? 
-                                                  samplesInOverflowBuffer :
-                                                  numSamplesExpected);
+                        samplesToCopy = ((samplesInOverflowBuffer <= numSamplesExpected) ?
+                                         samplesInOverflowBuffer :
+                                         numSamplesExpected);
 
-                      //  std::cout << " " << std::endl;
-                      //  std::cout << "Copying " << samplesToCopy << " samples from overflow buffer of " << samplesInOverflowBuffer << " samples." << std::endl;
+                        //  std::cout << " " << std::endl;
+                        //  std::cout << "Copying " << samplesToCopy << " samples from overflow buffer of " << samplesInOverflowBuffer << " samples." << std::endl;
 
                         if (samplesToCopy > 0)
                         {
 
                             buffer.addFrom(0,    // destination channel
-                               0,                // destination start sample
-                               *overflowBuffer,  // source
-                               0,                // source channel
-                               0,                // source start sample
-                               samplesToCopy,    // number of samples
-                               1.0f              // gain to apply
-                              );
+                                           0,                // destination start sample
+                                           *overflowBuffer,  // source
+                                           0,                // source channel
+                                           0,                // source start sample
+                                           samplesToCopy,    // number of samples
+                                           1.0f              // gain to apply
+                                          );
 
                             buffer.addFrom(1,       // destination channel
-                               0,           // destination start sample
-                               *overflowBuffer,      // source
-                               1,           // source channel
-                               0,           // source start sample
-                               samplesToCopy, //  number of samples
-                               1.0f       // gain to apply
-                              );
+                                           0,           // destination start sample
+                                           *overflowBuffer,      // source
+                                           1,           // source channel
+                                           0,           // source start sample
+                                           samplesToCopy, //  number of samples
+                                           1.0f       // gain to apply
+                                          );
 
 
                             int leftoverSamples = samplesInOverflowBuffer - samplesToCopy;
 
-                       //     std::cout << "Samples remaining in overflow buffer: " << leftoverSamples << std::endl;
+                            //     std::cout << "Samples remaining in overflow buffer: " << leftoverSamples << std::endl;
 
                             if (leftoverSamples > 0)
                             {
 
                                 // move remaining samples to the backup buffer
 
-                                 backupBuffer->addFrom(0, // destination channel
-                                   0,                     // destination start sample
-                                   *overflowBuffer,       // source
-                                   0,                     // source channel
-                                   samplesToCopy,         // source start sample
-                                   leftoverSamples,       // number of samples
-                                   1.0f                   // gain to apply
-                                  );
+                                backupBuffer->addFrom(0, // destination channel
+                                                      0,                     // destination start sample
+                                                      *overflowBuffer,       // source
+                                                      0,                     // source channel
+                                                      samplesToCopy,         // source start sample
+                                                      leftoverSamples,       // number of samples
+                                                      1.0f                   // gain to apply
+                                                     );
 
                                 backupBuffer->addFrom(1,  // destination channel
-                                   0,                     // destination start sample
-                                   *overflowBuffer,        // source
-                                   1,                     // source channel
-                                   samplesToCopy,         // source start sample
-                                   leftoverSamples,       // number of samples
-                                   1.0f                   // gain to apply
-                                  );
+                                                      0,                     // destination start sample
+                                                      *overflowBuffer,        // source
+                                                      1,                     // source channel
+                                                      samplesToCopy,         // source start sample
+                                                      leftoverSamples,       // number of samples
+                                                      1.0f                   // gain to apply
+                                                     );
 
                             }
 
@@ -298,68 +300,69 @@ void AudioNode::process(AudioSampleBuffer& buffer,
 
                     int remainingSamples = numSamplesExpected - samplesToCopy;
 
-                  //  std::cout << "Copying " << remainingSamples << " samples from incoming buffer of " << nSamples << " samples." << std::endl;
+                    //  std::cout << "Copying " << remainingSamples << " samples from incoming buffer of " << nSamples << " samples." << std::endl;
 
-                    int samplesToCopy2 = ((remainingSamples <= nSamples) ? 
-                                                  remainingSamples :
-                                                  nSamples);
+                    int samplesToCopy2 = ((remainingSamples <= nSamples) ?
+                                          remainingSamples :
+                                          nSamples);
 
                     if (samplesToCopy2 > 0)
                     {
 
                         buffer.addFrom(0,       // destination channel
-                                   samplesToCopy,           // destination start sample
-                                   buffer,      // source
-                                   i,           // source channel
-                                   0,           // source start sample
-                                   remainingSamples, //  number of samples
-                                   gain       // gain to apply
-                                  );
+                                       samplesToCopy,           // destination start sample
+                                       buffer,      // source
+                                       i,           // source channel
+                                       0,           // source start sample
+                                       remainingSamples, //  number of samples
+                                       gain       // gain to apply
+                                      );
 
                         buffer.addFrom(1,       // destination channel
-                                   samplesToCopy,           // destination start sample
-                                   buffer,      // source
-                                   i,           // source channel
-                                   0,           // source start sample
-                                   remainingSamples, //  number of samples
-                                   gain       // gain to apply
-                                  );
+                                       samplesToCopy,           // destination start sample
+                                       buffer,      // source
+                                       i,           // source channel
+                                       0,           // source start sample
+                                       remainingSamples, //  number of samples
+                                       gain       // gain to apply
+                                      );
 
                     }
 
                     orphanedSamples = nSamples - samplesToCopy2;
 
-                   // std::cout << "Samples remaining in incoming buffer: " << orphanedSamples << std::endl;
+                    // std::cout << "Samples remaining in incoming buffer: " << orphanedSamples << std::endl;
 
 
                     if (orphanedSamples > 0)
                     {
-                          backupBuffer->addFrom(0,       // destination channel
-                                   samplesInBackupBuffer,           // destination start sample
-                                   buffer,      // source
-                                   i,           // source channel
-                                   remainingSamples,           // source start sample
-                                   orphanedSamples, //  number of samples
-                                   gain       // gain to apply
-                                  );
-
-                          backupBuffer->addFrom(0,       // destination channel
-                                   samplesInBackupBuffer,           // destination start sample
-                                   buffer,      // source
-                                   i,           // source channel
-                                   remainingSamples,           // source start sample
-                                   orphanedSamples, //  number of samples
-                                   gain       // gain to apply
-                                  );
+                        backupBuffer->addFrom(0,       // destination channel
+                                              samplesInBackupBuffer,           // destination start sample
+                                              buffer,      // source
+                                              i,           // source channel
+                                              remainingSamples,           // source start sample
+                                              orphanedSamples, //  number of samples
+                                              gain       // gain to apply
+                                             );
+
+                        backupBuffer->addFrom(0,       // destination channel
+                                              samplesInBackupBuffer,           // destination start sample
+                                              buffer,      // source
+                                              i,           // source channel
+                                              remainingSamples,           // source start sample
+                                              orphanedSamples, //  number of samples
+                                              gain       // gain to apply
+                                             );
 
                     }
-                    
+
                     // Simple implementation of a "noise gate" on audio output
-                    float *leftChannelData = buffer.getWritePointer(0);
-                    float *rightChannelData = buffer.getWritePointer(1);
+                    float* leftChannelData = buffer.getWritePointer(0);
+                    float* rightChannelData = buffer.getWritePointer(1);
                     float gateLevel = noiseGateLevel * gain; // uVolts scaled by gain
-                    
-                    for (int m = 0; m < buffer.getNumSamples(); m++) {
+
+                    for (int m = 0; m < buffer.getNumSamples(); m++)
+                    {
                         if (fabs(leftChannelData[m])  < gateLevel)
                             leftChannelData[m] = 0;
                         if (fabs(rightChannelData[m]) < gateLevel)
@@ -372,6 +375,6 @@ void AudioNode::process(AudioSampleBuffer& buffer,
 
         samplesInBackupBuffer += orphanedSamples;
         nSamples = numSamplesExpected;
-   
+
     }
 }
diff --git a/Source/Processors/AudioNode.h b/Source/Processors/AudioNode.h
index 8ebc5296d02e893ff940706da009b745fb5ea4b3..011ae3af5597005c92028faec62966e323c9babe 100755
--- a/Source/Processors/AudioNode.h
+++ b/Source/Processors/AudioNode.h
@@ -93,7 +93,7 @@ public:
 
     /** A pointer to the AudioNode's editor. */
     ScopedPointer<AudioEditor> audioEditor;
-    
+
     void updateBufferSize();
 
     void prepareToPlay(double sampleRate_, int estimatedSamplesPerBlock);
diff --git a/Source/Processors/AudioResamplingNode.cpp b/Source/Processors/AudioResamplingNode.cpp
index 8f68fee66854b8114afa5ef9b19abca883cb6fac..db313b5ba3e3079fa269b77244f09ab529f62dac 100644
--- a/Source/Processors/AudioResamplingNode.cpp
+++ b/Source/Processors/AudioResamplingNode.cpp
@@ -91,7 +91,7 @@ void AudioResamplingNode::setParameter(int parameterIndex, float newValue)
 void AudioResamplingNode::prepareToPlay(double sampleRate_, int estimatedSamplesPerBlock)
 {
 
-   // std::cout << "AudioResamplingNode preparing to play." << std::endl;
+    // std::cout << "AudioResamplingNode preparing to play." << std::endl;
 
     if (destBufferIsTempBuffer)
     {
@@ -109,8 +109,8 @@ void AudioResamplingNode::prepareToPlay(double sampleRate_, int estimatedSamples
 
     destBufferPos = 0;
 
-   // std::cout << "Temp buffer size: " << tempBuffer->getNumChannels() << " x "
-   //           << tempBuffer->getNumSamples() << std::endl;
+    // std::cout << "Temp buffer size: " << tempBuffer->getNumChannels() << " x "
+    //           << tempBuffer->getNumSamples() << std::endl;
 
     updateFilter();
 
diff --git a/Source/Processors/Channel.cpp b/Source/Processors/Channel.cpp
index d00545ad9cbd20d9563e51827d569128abdccb29..95a8811422ac2aa824b8fb917261c6a269d6fb3b 100644
--- a/Source/Processors/Channel.cpp
+++ b/Source/Processors/Channel.cpp
@@ -26,7 +26,6 @@
 
 Channel::Channel(GenericProcessor* p, int n) : num(n), eventType(0), processor(p), sampleRate(44100.0), bitVolts(1.0f),
 	isADCchannel(false),isEventChannel(false), isMonitored(false), isEnabled(true), isRecording(false), recordIndex(-1)
-    
 {
     nodeId = p->getNodeId();
 
@@ -39,7 +38,7 @@ Channel::Channel(const Channel& ch)
     isEventChannel = ch.isEventChannel;
     isEnabled = ch.isEnabled;
     isMonitored = false;
-	isADCchannel = ch.isADCchannel;
+    isADCchannel = ch.isADCchannel;
     sampleRate = ch.sampleRate;
     bitVolts = ch.bitVolts;
     name = ch.name;
@@ -65,9 +64,9 @@ String Channel::getName()
 void Channel::setRecordState(bool t)
 {
 
-   isRecording = t;
-   //std::cout << "Setting record status for channel " <<
-     //            nodeId << " - " << num << " to " << t << std::endl;
+    isRecording = t;
+    //std::cout << "Setting record status for channel " <<
+    //            nodeId << " - " << num << " to " << t << std::endl;
 
 }
 
diff --git a/Source/Processors/Channel.h b/Source/Processors/Channel.h
index 0525ff5fdb72b7b7e273baf619de0286c8afaf2f..1069523c25ccb647851c536b9be16314aea7b091 100644
--- a/Source/Processors/Channel.h
+++ b/Source/Processors/Channel.h
@@ -74,7 +74,10 @@ public:
     void setRecordState(bool t); // {isRecording = t;}
 
     /** Sets whether or not the channel will record. */
-    bool getRecordState() {return isRecording;}
+    bool getRecordState()
+    {
+        return isRecording;
+    }
 
     /** The channel number.*/
     int num;
@@ -91,7 +94,7 @@ public:
     // crucial information:
     float sampleRate;
     float bitVolts;
-    
+
     // boolean values:
     bool isEventChannel;
     bool isADCchannel;
@@ -105,7 +108,7 @@ public:
 
 private:
 
-    bool isRecording; 
+    bool isRecording;
 
     /** Generates a default name, based on the channel number. */
     void createDefaultName();
diff --git a/Source/Processors/ChannelMappingNode.cpp b/Source/Processors/ChannelMappingNode.cpp
index b503bdf64ad3bbd9d68dd60f9f256f672bf36581..f99ea6c6f5451e77218c647fa048e503eca54abd 100644
--- a/Source/Processors/ChannelMappingNode.cpp
+++ b/Source/Processors/ChannelMappingNode.cpp
@@ -28,21 +28,21 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 ChannelMappingNode::ChannelMappingNode()
-	: GenericProcessor("Channel Map"), previousChannelCount(0), channelBuffer(1,10000)
+    : GenericProcessor("Channel Map"), previousChannelCount(0), channelBuffer(1,10000)
 {
-	referenceArray.resize(1024); // make room for 1024 channels
-	channelArray.resize(1024);
-
-	for (int i = 0; i < referenceArray.size(); i++)
-	{
-		channelArray.set(i, i);
-		referenceArray.set(i,-1);
-		enabledChannelArray.set(i,true);
-	}
-	for (int i = 0; i < NUM_REFERENCES; i++)
-	{
-		referenceChannels.set(i, -1);
-	}
+    referenceArray.resize(1024); // make room for 1024 channels
+    channelArray.resize(1024);
+
+    for (int i = 0; i < referenceArray.size(); i++)
+    {
+        channelArray.set(i, i);
+        referenceArray.set(i,-1);
+        enabledChannelArray.set(i,true);
+    }
+    for (int i = 0; i < NUM_REFERENCES; i++)
+    {
+        referenceChannels.set(i, -1);
+    }
 
 }
 
@@ -53,57 +53,57 @@ ChannelMappingNode::~ChannelMappingNode()
 
 AudioProcessorEditor* ChannelMappingNode::createEditor()
 {
-	editor = new ChannelMappingEditor(this, true);
+    editor = new ChannelMappingEditor(this, true);
 
-	//std::cout << "Creating editor." << std::endl;
+    //std::cout << "Creating editor." << std::endl;
 
-	return editor;
+    return editor;
 }
 
 
 
 void ChannelMappingNode::updateSettings()
 {
-	int j;
-	if (getNumInputs() > 0)
-		channelBuffer.setSize(getNumInputs(), 10000);
-
-	if (getNumInputs() != previousChannelCount)
-	{
-		previousChannelCount = getNumInputs();
-		if (editorIsConfigured)
-		{
-			j = 0;
-			for (int i = 0; i < getNumInputs(); i++)
-			{
-				if (enabledChannelArray[i])
-				{
-					j++;
-				}
-				else
-				{
-					channels.remove(j);
-				}
-			}
-			settings.numOutputs = j;
-		}
-	}
-	else
-	{
-		j = 0;
-		for (int i = 0; i < getNumInputs(); i++)
-		{
-			if (enabledChannelArray[i])
-			{
-				j++;
-			}
-			else
-			{
-				channels.remove(j);
-			}
-		}
-		settings.numOutputs=j;
-	}
+    int j;
+    if (getNumInputs() > 0)
+        channelBuffer.setSize(getNumInputs(), 10000);
+
+    if (getNumInputs() != previousChannelCount)
+    {
+        previousChannelCount = getNumInputs();
+        if (editorIsConfigured)
+        {
+            j = 0;
+            for (int i = 0; i < getNumInputs(); i++)
+            {
+                if (enabledChannelArray[i])
+                {
+                    j++;
+                }
+                else
+                {
+                    channels.remove(j);
+                }
+            }
+            settings.numOutputs = j;
+        }
+    }
+    else
+    {
+        j = 0;
+        for (int i = 0; i < getNumInputs(); i++)
+        {
+            if (enabledChannelArray[i])
+            {
+                j++;
+            }
+            else
+            {
+                channels.remove(j);
+            }
+        }
+        settings.numOutputs=j;
+    }
 
 }
 
@@ -111,75 +111,75 @@ void ChannelMappingNode::updateSettings()
 void ChannelMappingNode::setParameter(int parameterIndex, float newValue)
 {
 
-	if (parameterIndex == 1)
-	{
-		referenceArray.set(currentChannel, (int) newValue);
-	}
-	else if (parameterIndex == 2)
-	{
-		referenceChannels.set((int) newValue, currentChannel);
-	}
-	else if (parameterIndex == 3)
-	{
-		enabledChannelArray.set(currentChannel, (newValue != 0) ? true : false);
-	}
-	else if (parameterIndex == 4)
-	{
-		editorIsConfigured = (newValue != 0) ? true : false;
-	}
-	else
-	{
-		channelArray.set(currentChannel, (int) newValue);
-	}
+    if (parameterIndex == 1)
+    {
+        referenceArray.set(currentChannel, (int) newValue);
+    }
+    else if (parameterIndex == 2)
+    {
+        referenceChannels.set((int) newValue, currentChannel);
+    }
+    else if (parameterIndex == 3)
+    {
+        enabledChannelArray.set(currentChannel, (newValue != 0) ? true : false);
+    }
+    else if (parameterIndex == 4)
+    {
+        editorIsConfigured = (newValue != 0) ? true : false;
+    }
+    else
+    {
+        channelArray.set(currentChannel, (int) newValue);
+    }
 
 }
 
 void ChannelMappingNode::process(AudioSampleBuffer& buffer,
-								 MidiBuffer& midiMessages,
-								 int& nSamples)
+                                 MidiBuffer& midiMessages,
+                                 int& nSamples)
 {
-	int j=0;
-	int i=0;
-	int realChan;
-
-	// use copy constructor to set the data to refer to
-	channelBuffer = buffer;
-
-	buffer.clear();
-
-	while (j < settings.numOutputs)
-	{
-		realChan = channelArray[i];
-		if ((realChan < channelBuffer.getNumChannels()) && (enabledChannelArray[realChan]))
-		{
-			// copy it back into the buffer according to the channel mapping
-			buffer.addFrom(j, // destChannel
-				0, // destStartSample
-				channelBuffer, // source
-				realChan, // sourceChannel
-				0, // sourceStartSample
-				nSamples, // numSamples
-				1.0f // gain to apply to source (positive for original signal)
-				);
-
-			// now do the referencing
-			if ((referenceArray[realChan] > -1) && (referenceChannels[referenceArray[realChan]] > -1)
-				&& (referenceChannels[referenceArray[realChan]] < channelBuffer.getNumChannels()))
-			{
-				buffer.addFrom(j, // destChannel
-					0, // destStartSample
-					channelBuffer, // source
-					referenceChannels[referenceArray[realChan]], // sourceChannel
-					0, // sourceStartSample
-					nSamples, // numSamples
-					-1.0f // gain to apply to source (negative for reference)
-					);
-			}
-			j++;
-		}
-		i++;
-
-	}
+    int j=0;
+    int i=0;
+    int realChan;
+
+    // use copy constructor to set the data to refer to
+    channelBuffer = buffer;
+
+    buffer.clear();
+
+    while (j < settings.numOutputs)
+    {
+        realChan = channelArray[i];
+        if ((realChan < channelBuffer.getNumChannels()) && (enabledChannelArray[realChan]))
+        {
+            // copy it back into the buffer according to the channel mapping
+            buffer.addFrom(j, // destChannel
+                           0, // destStartSample
+                           channelBuffer, // source
+                           realChan, // sourceChannel
+                           0, // sourceStartSample
+                           nSamples, // numSamples
+                           1.0f // gain to apply to source (positive for original signal)
+                          );
+
+            // now do the referencing
+            if ((referenceArray[realChan] > -1) && (referenceChannels[referenceArray[realChan]] > -1)
+                && (referenceChannels[referenceArray[realChan]] < channelBuffer.getNumChannels()))
+            {
+                buffer.addFrom(j, // destChannel
+                               0, // destStartSample
+                               channelBuffer, // source
+                               referenceChannels[referenceArray[realChan]], // sourceChannel
+                               0, // sourceStartSample
+                               nSamples, // numSamples
+                               -1.0f // gain to apply to source (negative for reference)
+                              );
+            }
+            j++;
+        }
+        i++;
+
+    }
 
 }
 
diff --git a/Source/Processors/ChannelMappingNode.h b/Source/Processors/ChannelMappingNode.h
index 3de6d77750b96f0bfa64a7990ba01265d70faa17..6a69d0e1398094f450275b0b8c51af07e6a8be22 100644
--- a/Source/Processors/ChannelMappingNode.h
+++ b/Source/Processors/ChannelMappingNode.h
@@ -65,12 +65,12 @@ public:
 private:
 
     Array<int> referenceArray;
-	Array<int> referenceChannels;
+    Array<int> referenceChannels;
     Array<int> channelArray;
-	Array<bool> enabledChannelArray;
+    Array<bool> enabledChannelArray;
 
-	int previousChannelCount;
-	bool editorIsConfigured;
+    int previousChannelCount;
+    bool editorIsConfigured;
 
     AudioSampleBuffer channelBuffer;
 
diff --git a/Source/Processors/DataThreads/DataBuffer.cpp b/Source/Processors/DataThreads/DataBuffer.cpp
index 3482fbab9543a9c1382910237450ac3e4243e84b..70a146bf1fa640bf4c2ec20c2ae8939a701d4a29 100755
--- a/Source/Processors/DataThreads/DataBuffer.cpp
+++ b/Source/Processors/DataThreads/DataBuffer.cpp
@@ -79,10 +79,10 @@ int DataBuffer::getNumSamples()
 int DataBuffer::readAllFromBuffer(AudioSampleBuffer& data, uint64* timestamp, int16* eventCodes, int maxSize)
 {
     // check to see if the maximum size is smaller than the total number of available ints
-    
+
     // Better version (1/27/14)?
     int numReady = abstractFifo.getNumReady();
-    int numItems = (maxSize < numReady ) ? maxSize : numReady;
+    int numItems = (maxSize < numReady) ? maxSize : numReady;
 
     // Original version:
     //int numItems = (maxSize < abstractFifo.getNumReady()) ?
diff --git a/Source/Processors/DataThreads/RHD2000Thread.cpp b/Source/Processors/DataThreads/RHD2000Thread.cpp
index e6f21378d8ee2895aa7a352dd6d540bfedcc4676..c5805e0a1b03a5e6f583ad764295c2766539f709 100644
--- a/Source/Processors/DataThreads/RHD2000Thread.cpp
+++ b/Source/Processors/DataThreads/RHD2000Thread.cpp
@@ -51,33 +51,33 @@ RHD2000Thread::RHD2000Thread(SourceNode* sn) : DataThread(sn),
     boardSampleRate(30000.0f),
     savedSampleRateIndex(16),
     cableLengthPortA(0.914f), cableLengthPortB(0.914f), cableLengthPortC(0.914f), cableLengthPortD(0.914f), // default is 3 feet (0.914 m),
-    audioOutputL(-1), audioOutputR(-1) 
+    audioOutputL(-1), audioOutputR(-1)
 {
     evalBoard = new Rhd2000EvalBoard;
     dataBlock = new Rhd2000DataBlock(1);
     dataBuffer = new DataBuffer(2, 10000); // start with 2 channels and automatically resize
 
     // Open Opal Kelly XEM6010 board.
-	// Returns 1 if successful, -1 if FrontPanel cannot be loaded, and -2 if XEM6010 can't be found.
+    // Returns 1 if successful, -1 if FrontPanel cannot be loaded, and -2 if XEM6010 can't be found.
     File executable = File::getSpecialLocation(File::currentExecutableFile);
 
-    #if defined(__APPLE__)
-        const String executableDirectory =
-            executable.getParentDirectory().getParentDirectory().getParentDirectory().getParentDirectory().getFullPathName();
-    #else
-	   const String executableDirectory = executable.getParentDirectory().getFullPathName();
-    
+#if defined(__APPLE__)
+    const String executableDirectory =
+        executable.getParentDirectory().getParentDirectory().getParentDirectory().getParentDirectory().getFullPathName();
+#else
+    const String executableDirectory = executable.getParentDirectory().getFullPathName();
+
+
+#endif
 
-    #endif
-    
     std::cout << executableDirectory << std::endl;
-    
 
-	String dirName = executableDirectory;
+
+    String dirName = executableDirectory;
     libraryFilePath = dirName;
-	libraryFilePath += File::separatorString;
-	libraryFilePath += okLIB_NAME;
-    
+    libraryFilePath += File::separatorString;
+    libraryFilePath += okLIB_NAME;
+
     if (openBoard(libraryFilePath))
     {
 
@@ -86,7 +86,7 @@ RHD2000Thread::RHD2000Thread(SourceNode* sn) : DataThread(sn),
 
         // automatically find connected headstages
         scanPorts(); // things would appear to run more smoothly if this were done after the editor has been created
-    
+
         if (0)
         {
             evalBoard->setContinuousRunMode(true);
@@ -108,11 +108,11 @@ RHD2000Thread::~RHD2000Thread()
         evalBoard->setLedDisplay(ledArray);
     }
 
-	if (deviceFound)
+    if (deviceFound)
     {
         evalBoard->flush();
         evalBoard->resetBoard();
-		evalBoard->resetFpga();
+        evalBoard->resetFpga();
     }
 
 
@@ -130,17 +130,17 @@ bool RHD2000Thread::openBoard(String pathToLibrary)
     }
     else if (return_code == -1) // dynamic library not found
     {
-        bool response = AlertWindow::showOkCancelBox (AlertWindow::NoIcon,
-                                   "Opal Kelly library not found.",
-                                    "The Opal Kelly library file was not found in the directory of the executable. Would you like to browse for it?",
-                                     "Yes", "No", 0, 0);
+        bool response = AlertWindow::showOkCancelBox(AlertWindow::NoIcon,
+                                                     "Opal Kelly library not found.",
+                                                     "The Opal Kelly library file was not found in the directory of the executable. Would you like to browse for it?",
+                                                     "Yes", "No", 0, 0);
         if (response)
         {
             // browse for file
             FileChooser fc("Select the library file...",
-                               File::getCurrentWorkingDirectory(),
-                               okLIB_EXTENSION,
-                               true);
+                           File::getCurrentWorkingDirectory(),
+                           okLIB_EXTENSION,
+                           true);
 
             if (fc.browseForFileToOpen())
             {
@@ -154,20 +154,25 @@ bool RHD2000Thread::openBoard(String pathToLibrary)
                 deviceFound = false;
             }
 
-        } else {
+        }
+        else
+        {
             deviceFound = false;
         }
-    } else if (return_code == -2) // board could not be opened
+    }
+    else if (return_code == -2)   // board could not be opened
     {
-        bool response = AlertWindow::showOkCancelBox (AlertWindow::NoIcon,
-                                   "Acquisition board not found.",
-                                    "An acquisition board could not be found. Please connect one now.",
-                                     "OK", "Cancel", 0, 0);
-    
+        bool response = AlertWindow::showOkCancelBox(AlertWindow::NoIcon,
+                                                     "Acquisition board not found.",
+                                                     "An acquisition board could not be found. Please connect one now.",
+                                                     "OK", "Cancel", 0, 0);
+
         if (response)
         {
             openBoard(libraryFilePath.getCharPointer()); // call recursively
-        } else {
+        }
+        else
+        {
             deviceFound = false;
         }
 
@@ -179,24 +184,24 @@ bool RHD2000Thread::openBoard(String pathToLibrary)
 
 bool RHD2000Thread::uploadBitfile(String bitfilename)
 {
-    
+
     deviceFound = true;
-    
+
     if (!evalBoard->uploadFpgaBitfile(bitfilename.toStdString()))
     {
         std::cout << "Couldn't upload bitfile from " << bitfilename << std::endl;
-        
-        bool response = AlertWindow::showOkCancelBox (AlertWindow::NoIcon,
-                                   "FPGA bitfile not found.",
-                                    "The rhd2000.bit file was not found in the directory of the executable. Would you like to browse for it?",
-                                     "Yes", "No", 0, 0);
+
+        bool response = AlertWindow::showOkCancelBox(AlertWindow::NoIcon,
+                                                     "FPGA bitfile not found.",
+                                                     "The rhd2000.bit file was not found in the directory of the executable. Would you like to browse for it?",
+                                                     "Yes", "No", 0, 0);
         if (response)
         {
             // browse for file
             FileChooser fc("Select the FPGA bitfile...",
-                               File::getCurrentWorkingDirectory(),
-                               "*.bit",
-                               true);
+                           File::getCurrentWorkingDirectory(),
+                           "*.bit",
+                           true);
 
             if (fc.browseForFileToOpen())
             {
@@ -209,12 +214,14 @@ bool RHD2000Thread::uploadBitfile(String bitfilename)
                 deviceFound = false;
             }
 
-        } else {
+        }
+        else
+        {
             deviceFound = false;
         }
 
     }
-    
+
     return deviceFound;
 
 }
@@ -223,18 +230,18 @@ void RHD2000Thread::initializeBoard()
 {
     String bitfilename;
 
-	File executable = File::getSpecialLocation(File::currentExecutableFile);
+    File executable = File::getSpecialLocation(File::currentExecutableFile);
 
-    #if defined(__APPLE__)
-    const String executableDirectory = 
-            executable.getParentDirectory().getParentDirectory().getParentDirectory().getParentDirectory().getFullPathName();
-    #else
-       const String executableDirectory = executable.getParentDirectory().getFullPathName();
-    #endif
+#if defined(__APPLE__)
+    const String executableDirectory =
+        executable.getParentDirectory().getParentDirectory().getParentDirectory().getParentDirectory().getFullPathName();
+#else
+    const String executableDirectory = executable.getParentDirectory().getFullPathName();
+#endif
 
-	bitfilename = executableDirectory;
-	bitfilename += File::separatorString;
-	bitfilename += "rhd2000.bit";
+    bitfilename = executableDirectory;
+    bitfilename += File::separatorString;
+    bitfilename += "rhd2000.bit";
 
     if (!uploadBitfile(bitfilename))
     {
@@ -283,7 +290,7 @@ void RHD2000Thread::initializeBoard()
 
 
 
-   // evalBoard->readDataBlock(dataBlock);
+    // evalBoard->readDataBlock(dataBlock);
 
     // Now that ADC calibration has been performed, we switch to the command sequence
     // that does not execute ADC calibration.
@@ -307,10 +314,10 @@ void RHD2000Thread::initializeBoard()
 
 void RHD2000Thread::scanPorts()
 {
-	if (!deviceFound) //Safety to avoid crashes if board not present
-	{
-		return;
-	}
+    if (!deviceFound) //Safety to avoid crashes if board not present
+    {
+        return;
+    }
     // Scan SPI ports
 
     int delay, stream, id;
@@ -398,13 +405,13 @@ void RHD2000Thread::scanPorts()
         // Record delay settings that yield good communication with the chip.
         for (stream = 0; stream < MAX_NUM_DATA_STREAMS; ++stream)//MAX_NUM_DATA_STREAMS; ++stream)
         {
-            // std::cout << "Stream number " << stream << ", delay = " << delay << std::endl;
+             std::cout << "Stream number " << stream << ", delay = " << delay << std::endl;
 
             id = deviceId(dataBlock, stream);
 
             if (id > 0) // 1 = RHD2132, 2 = RHD2216
             {
-                //  std::cout << "Device ID found: " << id << std::endl;
+                 std::cout << "Device ID found: " << id << std::endl;
 
                 sumGoodDelays.set(stream,sumGoodDelays[stream] + 1);
 
@@ -464,22 +471,22 @@ void RHD2000Thread::scanPorts()
     }
 
     evalBoard->setCableDelay(Rhd2000EvalBoard::PortA,
-                             optimumDelay[0]);
+                             max(optimumDelay[0],optimumDelay[1]));
     evalBoard->setCableDelay(Rhd2000EvalBoard::PortB,
-                             optimumDelay[1]);
+                             max(optimumDelay[2],optimumDelay[3]));
     evalBoard->setCableDelay(Rhd2000EvalBoard::PortC,
-                             optimumDelay[2]);
+                             max(optimumDelay[4],optimumDelay[5]));
     evalBoard->setCableDelay(Rhd2000EvalBoard::PortD,
-                             optimumDelay[3]);
+                             max(optimumDelay[6],optimumDelay[7]));
 
     cableLengthPortA =
-        evalBoard->estimateCableLengthMeters(optimumDelay[0]);
+        evalBoard->estimateCableLengthMeters(max(optimumDelay[0],optimumDelay[1]));
     cableLengthPortB =
-        evalBoard->estimateCableLengthMeters(optimumDelay[1]);
+        evalBoard->estimateCableLengthMeters(max(optimumDelay[2],optimumDelay[3]));
     cableLengthPortC =
-        evalBoard->estimateCableLengthMeters(optimumDelay[2]);
+        evalBoard->estimateCableLengthMeters(max(optimumDelay[4],optimumDelay[5]));
     cableLengthPortD =
-        evalBoard->estimateCableLengthMeters(optimumDelay[3]);
+        evalBoard->estimateCableLengthMeters(max(optimumDelay[6],optimumDelay[7]));
 
     setSampleRate(savedSampleRateIndex); // restore saved sample rate
 
@@ -663,7 +670,7 @@ int RHD2000Thread::setNoiseSlicerLevel(int level)
     // Level has been checked once before this and then is checked again in setAudioNoiseSuppress.
     // This may be overkill - maybe API should change so that the final function returns the value?
     actualNoiseSlicerLevel = level;
-    
+
     return actualNoiseSlicerLevel;
 }
 
@@ -869,10 +876,10 @@ void RHD2000Thread::setSampleRate(int sampleRateIndex, bool isTemporary)
 void RHD2000Thread::updateRegisters()
 {
 
-	if (!deviceFound) //Safety to avoid crashes loading a chain with Rythm node withouth a board
-	{
-		return;
-	}
+    if (!deviceFound) //Safety to avoid crashes loading a chain with Rythm node withouth a board
+    {
+        return;
+    }
     // Set up an RHD2000 register object using this sample rate to
     // optimize MUX-related register settings.
     chipRegisters.defineSampleRate(boardSampleRate);
@@ -988,13 +995,13 @@ bool RHD2000Thread::startAcquisition()
 
     //std::cout << "Setting max timestep." << std::endl;
     //evalBoard->setMaxTimeStep(100);
-    
+
 
     std::cout << "Starting acquisition." << std::endl;
     if (1)
     {
-       // evalBoard->setContinuousRunMode(false);
-      //  evalBoard->setMaxTimeStep(0);
+        // evalBoard->setContinuousRunMode(false);
+        //  evalBoard->setMaxTimeStep(0);
         std::cout << "Flushing FIFO." << std::endl;
         evalBoard->flush();
         evalBoard->setContinuousRunMode(true);
@@ -1032,29 +1039,29 @@ bool RHD2000Thread::stopAcquisition()
         std::cout << "Thread failed to exit, continuing anyway..." << std::endl;
     }
 
-	if (deviceFound)
+    if (deviceFound)
     {
         evalBoard->setContinuousRunMode(false);
         evalBoard->setMaxTimeStep(0);
         std::cout << "Flushing FIFO." << std::endl;
         evalBoard->flush();
-     //   evalBoard->setContinuousRunMode(true);
-     //   evalBoard->run();
+        //   evalBoard->setContinuousRunMode(true);
+        //   evalBoard->run();
 
     }
 
     dataBuffer->clear();
 
-	if (deviceFound)
-	{
-		cout << "Number of 16-bit words in FIFO: " << evalBoard->numWordsInFifo() << endl;
+    if (deviceFound)
+    {
+        cout << "Number of 16-bit words in FIFO: " << evalBoard->numWordsInFifo() << endl;
 
-		// std::cout << "Stopped eval board." << std::endl;
+        // std::cout << "Stopped eval board." << std::endl;
 
 
-		int ledArray[8] = {1, 0, 0, 0, 0, 0, 0, 0};
-		evalBoard->setLedDisplay(ledArray);
-	}
+        int ledArray[8] = {1, 0, 0, 0, 0, 0, 0, 0};
+        evalBoard->setLedDisplay(ledArray);
+    }
     isTransmitting = false;
 
     return true;
@@ -1086,9 +1093,9 @@ bool RHD2000Thread::updateBuffer()
 
                     for (int chan = 0; chan < numChannelsPerDataStream[dataStream]; chan++)
                     {
-                        
-                      //  std::cout << "reading sample stream " << streamNumber << " chan " << chan << " sample "<< samp << std::endl;
-                        
+
+                        //  std::cout << "reading sample stream " << streamNumber << " chan " << chan << " sample "<< samp << std::endl;
+
                         channel++;
 
                         int value = dataBlock->amplifierData[streamNumber][chan][samp];
@@ -1112,19 +1119,19 @@ bool RHD2000Thread::updateBuffer()
                     if (samp % 4 == 1)   // every 4th sample should have auxiliary input data
                     {
 
-                       // std::cout << "reading sample stream " << streamNumber << " aux ADCs " << std::endl;
+                        // std::cout << "reading sample stream " << streamNumber << " aux ADCs " << std::endl;
 
                         channel++;
                         thisSample[channel] = 0.0374 *
                                               float(dataBlock->auxiliaryData[streamNumber][1][samp+0] - 45000.0f) ;
-                                              // constant offset keeps the values visible in the LFP Viewer
+                        // constant offset keeps the values visible in the LFP Viewer
 
                         auxBuffer[channel] = thisSample[channel];
 
                         channel++;
                         thisSample[channel] = 0.0374 *
                                               float(dataBlock->auxiliaryData[streamNumber][1][samp+1] - 45000.0f) ;
-                                              // constant offset keeps the values visible in the LFP Viewer
+                        // constant offset keeps the values visible in the LFP Viewer
 
                         auxBuffer[channel] = thisSample[channel];
 
@@ -1132,7 +1139,7 @@ bool RHD2000Thread::updateBuffer()
                         channel++;
                         thisSample[channel] = 0.0374 *
                                               float(dataBlock->auxiliaryData[streamNumber][1][samp+2] - 45000.0f) ;
-                                              // constant offset keeps the values visible in the LFP Viewer
+                        // constant offset keeps the values visible in the LFP Viewer
 
                         auxBuffer[channel] = thisSample[channel];
 
diff --git a/Source/Processors/DataThreads/RHD2000Thread.h b/Source/Processors/DataThreads/RHD2000Thread.h
index f08fe07d7e78141f49e9bf23e33536c4e10d5b7c..0f9667b4645ad8d2a90abb80db90df46bedcbf4a 100644
--- a/Source/Processors/DataThreads/RHD2000Thread.h
+++ b/Source/Processors/DataThreads/RHD2000Thread.h
@@ -72,7 +72,7 @@ public:
 
     double setUpperBandwidth(double upper); // set desired BW, returns actual BW
     double setLowerBandwidth(double lower);
-    
+
     int setNoiseSlicerLevel(int level);
 
     void scanPorts();
diff --git a/Source/Processors/DataThreads/rhythm-api/okFrontPanelDLL.cpp b/Source/Processors/DataThreads/rhythm-api/okFrontPanelDLL.cpp
index 45b7e186c2ae70720042a103339727282b2806cb..0475827d736c0903e79b50206ccf2f8e0724f436 100755
--- a/Source/Processors/DataThreads/rhythm-api/okFrontPanelDLL.cpp
+++ b/Source/Processors/DataThreads/rhythm-api/okFrontPanelDLL.cpp
@@ -69,12 +69,12 @@ dll_entrypoint(DLL* dll, const char* name)
     {
         printf("Failed to load %s. Error code %d\n", name, GetLastError());
     }
-    return((DLL_EP)proc);
+    return ((DLL_EP)proc);
 #else
     void* handle = (void*)dll;
     DLL_EP ep;
     ep = (DLL_EP)dlsym(handle, name);
-    return((dlerror()==0) ? (ep) : ((DLL_EP)NULL));
+    return ((dlerror()==0) ? (ep) : ((DLL_EP)NULL));
 #endif
 }
 
@@ -83,7 +83,7 @@ dll_entrypoint(DLL* dll, const char* name)
 static DLL*
 dll_load(okFP_dll_pchar libname)
 {
-    return((DLL*) LoadLibraryW(libname));
+    return ((DLL*) LoadLibraryW(libname));
 }
 #elif defined(_WIN32)
 static DLL*
@@ -95,9 +95,9 @@ dll_load(okFP_dll_pchar libname)
     //mbstowcs_s(&pReturnValue, dest, 32767, libname, 32767);
     //return((DLL *) LoadLibraryW(dest));
 
-    return((DLL*) LoadLibraryA(libname));
+    return ((DLL*) LoadLibraryA(libname));
 
-    return((DLL*) LoadLibraryA(libname));   // This was the original code from Opal Kelly
+    return ((DLL*) LoadLibraryA(libname));  // This was the original code from Opal Kelly
 }
 #else
 static DLL*
@@ -107,7 +107,7 @@ dll_load(okFP_dll_pchar libname)
     dll = dlopen(libname, RTLD_NOW);
     if (!dll)
         printf("%s\n", (char*)dlerror());
-    return(dll);
+    return (dll);
 }
 #endif
 
@@ -133,11 +133,11 @@ dll_unload(DLL* dll)
 //------------------------------------------------------------------------
 bool okCPLL22150::to_bool(Bool x)
 {
-    return((x==TRUE)?(true):(false));
+    return ((x==TRUE)?(true):(false));
 }
 Bool okCPLL22150::from_bool(bool x)
 {
-    return((x==true)?(TRUE):(FALSE));
+    return ((x==true)?(TRUE):(FALSE));
 }
 okCPLL22150::okCPLL22150()
 {
@@ -153,23 +153,23 @@ void okCPLL22150::SetReference(double freq, bool extosc)
 }
 double okCPLL22150::GetReference()
 {
-    return(okPLL22150_GetReference(h));
+    return (okPLL22150_GetReference(h));
 }
 bool okCPLL22150::SetVCOParameters(int p, int q)
 {
-    return(to_bool(okPLL22150_SetVCOParameters(h,p,q)));
+    return (to_bool(okPLL22150_SetVCOParameters(h,p,q)));
 }
 int okCPLL22150::GetVCOP()
 {
-    return(okPLL22150_GetVCOP(h));
+    return (okPLL22150_GetVCOP(h));
 }
 int okCPLL22150::GetVCOQ()
 {
-    return(okPLL22150_GetVCOQ(h));
+    return (okPLL22150_GetVCOQ(h));
 }
 double okCPLL22150::GetVCOFrequency()
 {
-    return(okPLL22150_GetVCOFrequency(h));
+    return (okPLL22150_GetVCOFrequency(h));
 }
 void okCPLL22150::SetDiv1(DividerSource divsrc, int n)
 {
@@ -181,19 +181,19 @@ void okCPLL22150::SetDiv2(DividerSource divsrc, int n)
 }
 okCPLL22150::DividerSource okCPLL22150::GetDiv1Source()
 {
-    return((DividerSource) okPLL22150_GetDiv1Source(h));
+    return ((DividerSource) okPLL22150_GetDiv1Source(h));
 }
 okCPLL22150::DividerSource okCPLL22150::GetDiv2Source()
 {
-    return((DividerSource) okPLL22150_GetDiv2Source(h));
+    return ((DividerSource) okPLL22150_GetDiv2Source(h));
 }
 int okCPLL22150::GetDiv1Divider()
 {
-    return(okPLL22150_GetDiv1Divider(h));
+    return (okPLL22150_GetDiv1Divider(h));
 }
 int okCPLL22150::GetDiv2Divider()
 {
-    return(okPLL22150_GetDiv2Divider(h));
+    return (okPLL22150_GetDiv2Divider(h));
 }
 void okCPLL22150::SetOutputSource(int output, okCPLL22150::ClockSource clksrc)
 {
@@ -205,15 +205,15 @@ void okCPLL22150::SetOutputEnable(int output, bool enable)
 }
 okCPLL22150::ClockSource okCPLL22150::GetOutputSource(int output)
 {
-    return((ClockSource)okPLL22150_GetOutputSource(h, output));
+    return ((ClockSource)okPLL22150_GetOutputSource(h, output));
 }
 double okCPLL22150::GetOutputFrequency(int output)
 {
-    return(okPLL22150_GetOutputFrequency(h, output));
+    return (okPLL22150_GetOutputFrequency(h, output));
 }
 bool okCPLL22150::IsOutputEnabled(int output)
 {
-    return(to_bool(okPLL22150_IsOutputEnabled(h, output)));
+    return (to_bool(okPLL22150_IsOutputEnabled(h, output)));
 }
 void okCPLL22150::InitFromProgrammingInfo(unsigned char* buf)
 {
@@ -229,11 +229,11 @@ void okCPLL22150::GetProgrammingInfo(unsigned char* buf)
 //------------------------------------------------------------------------
 bool okCPLL22393::to_bool(Bool x)
 {
-    return((x==TRUE)?(true):(false));
+    return ((x==TRUE)?(true):(false));
 }
 Bool okCPLL22393::from_bool(bool x)
 {
-    return((x==true)?(TRUE):(FALSE));
+    return ((x==true)?(TRUE):(FALSE));
 }
 okCPLL22393::okCPLL22393()
 {
@@ -249,23 +249,23 @@ void okCPLL22393::SetReference(double freq)
 }
 double okCPLL22393::GetReference()
 {
-    return(okPLL22393_GetReference(h));
+    return (okPLL22393_GetReference(h));
 }
 bool okCPLL22393::SetPLLParameters(int n, int p, int q, bool enable)
 {
-    return(to_bool(okPLL22393_SetPLLParameters(h, n, p, q, from_bool(enable))));
+    return (to_bool(okPLL22393_SetPLLParameters(h, n, p, q, from_bool(enable))));
 }
 bool okCPLL22393::SetPLLLF(int n, int lf)
 {
-    return(to_bool(okPLL22393_SetPLLLF(h, n, lf)));
+    return (to_bool(okPLL22393_SetPLLLF(h, n, lf)));
 }
 bool okCPLL22393::SetOutputDivider(int n, int div)
 {
-    return(to_bool(okPLL22393_SetOutputDivider(h, n, div)));
+    return (to_bool(okPLL22393_SetOutputDivider(h, n, div)));
 }
 bool okCPLL22393::SetOutputSource(int n, okCPLL22393::ClockSource clksrc)
 {
-    return(to_bool(okPLL22393_SetOutputSource(h, n, (ok_ClockSource_22393)clksrc)));
+    return (to_bool(okPLL22393_SetOutputSource(h, n, (ok_ClockSource_22393)clksrc)));
 }
 void okCPLL22393::SetOutputEnable(int n, bool enable)
 {
@@ -273,35 +273,35 @@ void okCPLL22393::SetOutputEnable(int n, bool enable)
 }
 int okCPLL22393::GetPLLP(int n)
 {
-    return(okPLL22393_GetPLLP(h, n));
+    return (okPLL22393_GetPLLP(h, n));
 }
 int okCPLL22393::GetPLLQ(int n)
 {
-    return(okPLL22393_GetPLLQ(h, n));
+    return (okPLL22393_GetPLLQ(h, n));
 }
 double okCPLL22393::GetPLLFrequency(int n)
 {
-    return(okPLL22393_GetPLLFrequency(h, n));
+    return (okPLL22393_GetPLLFrequency(h, n));
 }
 int okCPLL22393::GetOutputDivider(int n)
 {
-    return(okPLL22393_GetOutputDivider(h, n));
+    return (okPLL22393_GetOutputDivider(h, n));
 }
 okCPLL22393::ClockSource okCPLL22393::GetOutputSource(int n)
 {
-    return((ClockSource) okPLL22393_GetOutputSource(h, n));
+    return ((ClockSource) okPLL22393_GetOutputSource(h, n));
 }
 double okCPLL22393::GetOutputFrequency(int n)
 {
-    return(okPLL22393_GetOutputFrequency(h, n));
+    return (okPLL22393_GetOutputFrequency(h, n));
 }
 bool okCPLL22393::IsOutputEnabled(int n)
 {
-    return(to_bool(okPLL22393_IsOutputEnabled(h, n)));
+    return (to_bool(okPLL22393_IsOutputEnabled(h, n)));
 }
 bool okCPLL22393::IsPLLEnabled(int n)
 {
-    return(to_bool(okPLL22393_IsPLLEnabled(h, n)));
+    return (to_bool(okPLL22393_IsPLLEnabled(h, n)));
 }
 void okCPLL22393::InitFromProgrammingInfo(unsigned char* buf)
 {
@@ -317,11 +317,11 @@ void okCPLL22393::GetProgrammingInfo(unsigned char* buf)
 //------------------------------------------------------------------------
 bool okCFrontPanel::to_bool(Bool x)
 {
-    return((x==TRUE)?(true):(false));
+    return ((x==TRUE)?(true):(false));
 }
 Bool okCFrontPanel::from_bool(bool x)
 {
-    return((x==true)?(TRUE):(FALSE));
+    return ((x==true)?(TRUE):(FALSE));
 }
 okCFrontPanel::okCFrontPanel()
 {
@@ -333,40 +333,40 @@ okCFrontPanel::~okCFrontPanel()
 }
 int okCFrontPanel::GetHostInterfaceWidth()
 {
-    return(okFrontPanel_GetHostInterfaceWidth(h));
+    return (okFrontPanel_GetHostInterfaceWidth(h));
 }
 bool okCFrontPanel::IsHighSpeed()
 {
-    return(to_bool(okFrontPanel_IsHighSpeed(h)));
+    return (to_bool(okFrontPanel_IsHighSpeed(h)));
 }
 okCFrontPanel::BoardModel okCFrontPanel::GetBoardModel()
 {
-    return((okCFrontPanel::BoardModel)okFrontPanel_GetBoardModel(h));
+    return ((okCFrontPanel::BoardModel)okFrontPanel_GetBoardModel(h));
 }
 std::string okCFrontPanel::GetBoardModelString(okCFrontPanel::BoardModel m)
 {
     char str[MAX_BOARDMODELSTRING_LENGTH];
     okFrontPanel_GetBoardModelString(h, (ok_BoardModel)m, str);
-    return(std::string(str));
+    return (std::string(str));
 }
 int okCFrontPanel::GetDeviceCount()
 {
-    return(okFrontPanel_GetDeviceCount(h));
+    return (okFrontPanel_GetDeviceCount(h));
 }
 okCFrontPanel::BoardModel okCFrontPanel::GetDeviceListModel(int num)
 {
-    return((okCFrontPanel::BoardModel)okFrontPanel_GetDeviceListModel(h, num));
+    return ((okCFrontPanel::BoardModel)okFrontPanel_GetDeviceListModel(h, num));
 }
 std::string okCFrontPanel::GetDeviceListSerial(int num)
 {
     char str[MAX_SERIALNUMBER_LENGTH+1];
     okFrontPanel_GetDeviceListSerial(h, num, str);
     str[MAX_SERIALNUMBER_LENGTH] = '\0';
-    return(std::string(str));
+    return (std::string(str));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::GetDeviceInfo(okTDeviceInfo* info)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_GetDeviceInfo(h, info));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_GetDeviceInfo(h, info));
 }
 void okCFrontPanel::EnableAsynchronousTransfers(bool enable)
 {
@@ -374,31 +374,31 @@ void okCFrontPanel::EnableAsynchronousTransfers(bool enable)
 }
 okCFrontPanel::ErrorCode okCFrontPanel::OpenBySerial(std::string str)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_OpenBySerial(h, str.c_str()));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_OpenBySerial(h, str.c_str()));
 }
 bool okCFrontPanel::IsOpen()
 {
-    return(to_bool(okFrontPanel_IsOpen(h)));
+    return (to_bool(okFrontPanel_IsOpen(h)));
 }
 int okCFrontPanel::GetDeviceMajorVersion()
 {
-    return(okFrontPanel_GetDeviceMajorVersion(h));
+    return (okFrontPanel_GetDeviceMajorVersion(h));
 }
 int okCFrontPanel::GetDeviceMinorVersion()
 {
-    return(okFrontPanel_GetDeviceMinorVersion(h));
+    return (okFrontPanel_GetDeviceMinorVersion(h));
 }
 std::string okCFrontPanel::GetSerialNumber()
 {
     char str[MAX_SERIALNUMBER_LENGTH+1];
     okFrontPanel_GetSerialNumber(h, str);
-    return(std::string(str));
+    return (std::string(str));
 }
 std::string okCFrontPanel::GetDeviceID()
 {
     char str[MAX_DEVICEID_LENGTH+1];
     okFrontPanel_GetDeviceID(h, str);
-    return(std::string(str));
+    return (std::string(str));
 }
 void okCFrontPanel::SetDeviceID(const std::string str)
 {
@@ -406,7 +406,7 @@ void okCFrontPanel::SetDeviceID(const std::string str)
 }
 okCFrontPanel::ErrorCode okCFrontPanel::SetBTPipePollingInterval(int interval)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_SetBTPipePollingInterval(h, interval));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_SetBTPipePollingInterval(h, interval));
 }
 void okCFrontPanel::SetTimeout(int timeout)
 {
@@ -414,115 +414,115 @@ void okCFrontPanel::SetTimeout(int timeout)
 }
 okCFrontPanel::ErrorCode okCFrontPanel::ResetFPGA()
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_ResetFPGA(h));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_ResetFPGA(h));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::ConfigureFPGAFromMemory(unsigned char* data, const unsigned long length, void(*callback)(int, int, void*), void* arg)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_ConfigureFPGAFromMemory(h, data, length));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_ConfigureFPGAFromMemory(h, data, length));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::ConfigureFPGA(const std::string strFilename, void (*callback)(int, int, void*), void* arg)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_ConfigureFPGA(h, strFilename.c_str()));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_ConfigureFPGA(h, strFilename.c_str()));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::GetFPGABootResetProfile(okTFPGAResetProfile* profile)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_GetFPGABootResetProfile(h, profile));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_GetFPGABootResetProfile(h, profile));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::GetFPGAJTAGResetProfile(okTFPGAResetProfile* profile)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_GetFPGAJTAGResetProfile(h, profile));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_GetFPGAJTAGResetProfile(h, profile));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::ReadRegister(UINT32 addr, UINT32* data)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_ReadRegister(h, addr, data));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_ReadRegister(h, addr, data));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::ReadRegisterSet(okTRegisterSet* set)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_ReadRegisterSet(h, set));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_ReadRegisterSet(h, set));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::SetFPGABootResetProfile(okTFPGAResetProfile* profile)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_SetFPGABootResetProfile(h, profile));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_SetFPGABootResetProfile(h, profile));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::SetFPGAJTAGResetProfile(okTFPGAResetProfile* profile)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_SetFPGAJTAGResetProfile(h, profile));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_SetFPGAJTAGResetProfile(h, profile));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::FlashEraseSector(UINT32 address)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_FlashEraseSector(h, address));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_FlashEraseSector(h, address));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::FlashWrite(UINT32 address, UINT32 length, const UINT8* buf)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_FlashWrite(h, address, length, buf));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_FlashWrite(h, address, length, buf));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::FlashRead(UINT32 address, UINT32 length, UINT8* buf)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_FlashRead(h, address, length, buf));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_FlashRead(h, address, length, buf));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::WriteRegister(UINT32 addr, UINT32 data)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_WriteRegister(h, addr, data));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_WriteRegister(h, addr, data));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::WriteRegisterSet(okTRegisterSet* set)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_WriteRegisterSet(h, set));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_WriteRegisterSet(h, set));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::GetWireInValue(int epAddr, UINT32* val)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_GetWireInValue(h, epAddr, val));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_GetWireInValue(h, epAddr, val));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::WriteI2C(const int addr, int length, unsigned char* data)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_WriteI2C(h, addr, length, data));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_WriteI2C(h, addr, length, data));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::ReadI2C(const int addr, int length, unsigned char* data)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_ReadI2C(h, addr, length, data));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_ReadI2C(h, addr, length, data));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::GetPLL22150Configuration(okCPLL22150& pll)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_GetPLL22150Configuration(h, pll.h));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_GetPLL22150Configuration(h, pll.h));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::SetPLL22150Configuration(okCPLL22150& pll)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_SetPLL22150Configuration(h, pll.h));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_SetPLL22150Configuration(h, pll.h));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::GetEepromPLL22150Configuration(okCPLL22150& pll)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_GetEepromPLL22150Configuration(h, pll.h));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_GetEepromPLL22150Configuration(h, pll.h));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::SetEepromPLL22150Configuration(okCPLL22150& pll)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_SetEepromPLL22150Configuration(h, pll.h));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_SetEepromPLL22150Configuration(h, pll.h));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::GetPLL22393Configuration(okCPLL22393& pll)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_GetPLL22393Configuration(h, pll.h));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_GetPLL22393Configuration(h, pll.h));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::SetPLL22393Configuration(okCPLL22393& pll)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_SetPLL22393Configuration(h, pll.h));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_SetPLL22393Configuration(h, pll.h));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::GetEepromPLL22393Configuration(okCPLL22393& pll)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_GetEepromPLL22393Configuration(h, pll.h));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_GetEepromPLL22393Configuration(h, pll.h));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::SetEepromPLL22393Configuration(okCPLL22393& pll)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_SetEepromPLL22393Configuration(h, pll.h));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_SetEepromPLL22393Configuration(h, pll.h));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::LoadDefaultPLLConfiguration()
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_LoadDefaultPLLConfiguration(h));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_LoadDefaultPLLConfiguration(h));
 }
 bool okCFrontPanel::IsFrontPanelEnabled()
 {
-    return(to_bool(okFrontPanel_IsFrontPanelEnabled(h)));
+    return (to_bool(okFrontPanel_IsFrontPanelEnabled(h)));
 }
 bool okCFrontPanel::IsFrontPanel3Supported()
 {
-    return(to_bool(okFrontPanel_IsFrontPanel3Supported(h)));
+    return (to_bool(okFrontPanel_IsFrontPanel3Supported(h)));
 }
 //	void UnregisterAll();
 //	void AddEventHandler(okCEventHandler *handler);
@@ -532,7 +532,7 @@ void okCFrontPanel::UpdateWireIns()
 }
 okCFrontPanel::ErrorCode okCFrontPanel::SetWireInValue(int ep, unsigned long val, unsigned long mask)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_SetWireInValue(h, ep, val, mask));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_SetWireInValue(h, ep, val, mask));
 }
 void okCFrontPanel::UpdateWireOuts()
 {
@@ -540,11 +540,11 @@ void okCFrontPanel::UpdateWireOuts()
 }
 unsigned long okCFrontPanel::GetWireOutValue(int epAddr)
 {
-    return(okFrontPanel_GetWireOutValue(h, epAddr));
+    return (okFrontPanel_GetWireOutValue(h, epAddr));
 }
 okCFrontPanel::ErrorCode okCFrontPanel::ActivateTriggerIn(int epAddr, int bit)
 {
-    return((okCFrontPanel::ErrorCode) okFrontPanel_ActivateTriggerIn(h, epAddr, bit));
+    return ((okCFrontPanel::ErrorCode) okFrontPanel_ActivateTriggerIn(h, epAddr, bit));
 }
 void okCFrontPanel::UpdateTriggerOuts()
 {
@@ -552,27 +552,27 @@ void okCFrontPanel::UpdateTriggerOuts()
 }
 bool okCFrontPanel::IsTriggered(int epAddr, unsigned long mask)
 {
-    return(to_bool(okFrontPanel_IsTriggered(h, epAddr, mask)));
+    return (to_bool(okFrontPanel_IsTriggered(h, epAddr, mask)));
 }
 long okCFrontPanel::GetLastTransferLength()
 {
-    return(okFrontPanel_GetLastTransferLength(h));
+    return (okFrontPanel_GetLastTransferLength(h));
 }
 long okCFrontPanel::WriteToPipeIn(int epAddr, long length, unsigned char* data)
 {
-    return(okFrontPanel_WriteToPipeIn(h, epAddr, length, data));
+    return (okFrontPanel_WriteToPipeIn(h, epAddr, length, data));
 }
 long okCFrontPanel::ReadFromPipeOut(int epAddr, long length, unsigned char* data)
 {
-    return(okFrontPanel_ReadFromPipeOut(h, epAddr, length, data));
+    return (okFrontPanel_ReadFromPipeOut(h, epAddr, length, data));
 }
 long okCFrontPanel::WriteToBlockPipeIn(int epAddr, int blockSize, long length, unsigned char* data)
 {
-    return(okFrontPanel_WriteToBlockPipeIn(h, epAddr, blockSize, length, data));
+    return (okFrontPanel_WriteToBlockPipeIn(h, epAddr, blockSize, length, data));
 }
 long okCFrontPanel::ReadFromBlockPipeOut(int epAddr, int blockSize, long length, unsigned char* data)
 {
-    return(okFrontPanel_ReadFromBlockPipeOut(h, epAddr, blockSize, length, data));
+    return (okFrontPanel_ReadFromBlockPipeOut(h, epAddr, blockSize, length, data));
 }
 
 #endif // __cplusplus
@@ -805,7 +805,7 @@ okFrontPanel_GETWIREINVALUE_FN                   _okFrontPanel_GetWireInValue =
 const char*
 okFrontPanelDLL_GetVersionString()
 {
-    return(VERSION_STRING);
+    return (VERSION_STRING);
 }
 
 
@@ -816,7 +816,7 @@ okFrontPanelDLL_LoadLib(okFP_dll_pchar libname)
 {
     // Return TRUE if the DLL is already loaded.
     if (hLib)
-        return(TRUE);
+        return (TRUE);
 
     if (NULL == libname)
         hLib = dll_load(okLIB_NAME);
@@ -935,10 +935,10 @@ okFrontPanelDLL_LoadLib(okFP_dll_pchar libname)
 
     if (NULL == hLib)
     {
-        return(FALSE);
+        return (FALSE);
     }
 
-    return(TRUE);
+    return (TRUE);
 }
 
 
@@ -1077,9 +1077,9 @@ okDLLEXPORT okPLL22393_HANDLE DLL_ENTRY
 okPLL22393_Construct()
 {
     if (_okPLL22393_Construct)
-        return((*_okPLL22393_Construct)());
+        return ((*_okPLL22393_Construct)());
 
-    return(NULL);
+    return (NULL);
 }
 
 okDLLEXPORT void DLL_ENTRY
@@ -1107,40 +1107,40 @@ okDLLEXPORT double DLL_ENTRY
 okPLL22393_GetReference(okPLL22393_HANDLE pll)
 {
     if (_okPLL22393_GetReference)
-        return((*_okPLL22393_GetReference)(pll));
-    return(0.0);
+        return ((*_okPLL22393_GetReference)(pll));
+    return (0.0);
 }
 
 okDLLEXPORT Bool DLL_ENTRY
 okPLL22393_SetPLLParameters(okPLL22393_HANDLE pll, int n, int p, int q, Bool enable)
 {
     if (_okPLL22393_SetPLLParameters)
-        return((*_okPLL22393_SetPLLParameters)(pll, n, p, q, enable));
-    return(FALSE);
+        return ((*_okPLL22393_SetPLLParameters)(pll, n, p, q, enable));
+    return (FALSE);
 }
 
 okDLLEXPORT Bool DLL_ENTRY
 okPLL22393_SetPLLLF(okPLL22393_HANDLE pll, int n, int lf)
 {
     if (_okPLL22393_SetPLLLF)
-        return((*_okPLL22393_SetPLLLF)(pll, n, lf));
-    return(FALSE);
+        return ((*_okPLL22393_SetPLLLF)(pll, n, lf));
+    return (FALSE);
 }
 
 okDLLEXPORT Bool DLL_ENTRY
 okPLL22393_SetOutputDivider(okPLL22393_HANDLE pll, int n, int div)
 {
     if (_okPLL22393_SetOutputDivider)
-        return((*_okPLL22393_SetOutputDivider)(pll, n, div));
-    return(FALSE);
+        return ((*_okPLL22393_SetOutputDivider)(pll, n, div));
+    return (FALSE);
 }
 
 okDLLEXPORT Bool DLL_ENTRY
 okPLL22393_SetOutputSource(okPLL22393_HANDLE pll, int n, ok_ClockSource_22393 clksrc)
 {
     if (_okPLL22393_SetOutputSource)
-        return((*_okPLL22393_SetOutputSource)(pll, n, clksrc));
-    return(FALSE);
+        return ((*_okPLL22393_SetOutputSource)(pll, n, clksrc));
+    return (FALSE);
 }
 
 okDLLEXPORT void DLL_ENTRY
@@ -1154,64 +1154,64 @@ okDLLEXPORT int DLL_ENTRY
 okPLL22393_GetPLLP(okPLL22393_HANDLE pll, int n)
 {
     if (_okPLL22393_GetPLLP)
-        return((*_okPLL22393_GetPLLP)(pll, n));
-    return(0);
+        return ((*_okPLL22393_GetPLLP)(pll, n));
+    return (0);
 }
 
 okDLLEXPORT int DLL_ENTRY
 okPLL22393_GetPLLQ(okPLL22393_HANDLE pll, int n)
 {
     if (_okPLL22393_GetPLLQ)
-        return((*_okPLL22393_GetPLLQ)(pll, n));
-    return(0);
+        return ((*_okPLL22393_GetPLLQ)(pll, n));
+    return (0);
 }
 
 okDLLEXPORT double DLL_ENTRY
 okPLL22393_GetPLLFrequency(okPLL22393_HANDLE pll, int n)
 {
     if (_okPLL22393_GetPLLFrequency)
-        return((*_okPLL22393_GetPLLFrequency)(pll, n));
-    return(0.0);
+        return ((*_okPLL22393_GetPLLFrequency)(pll, n));
+    return (0.0);
 }
 
 okDLLEXPORT int DLL_ENTRY
 okPLL22393_GetOutputDivider(okPLL22393_HANDLE pll, int n)
 {
     if (_okPLL22393_GetOutputDivider)
-        return((*_okPLL22393_GetOutputDivider)(pll, n));
-    return(0);
+        return ((*_okPLL22393_GetOutputDivider)(pll, n));
+    return (0);
 }
 
 okDLLEXPORT ok_ClockSource_22393 DLL_ENTRY
 okPLL22393_GetOutputSource(okPLL22393_HANDLE pll, int n)
 {
     if (_okPLL22393_GetOutputSource)
-        return((*_okPLL22393_GetOutputSource)(pll, n));
-    return(ok_ClkSrc22393_Ref);
+        return ((*_okPLL22393_GetOutputSource)(pll, n));
+    return (ok_ClkSrc22393_Ref);
 }
 
 okDLLEXPORT double DLL_ENTRY
 okPLL22393_GetOutputFrequency(okPLL22393_HANDLE pll, int n)
 {
     if (_okPLL22393_GetOutputFrequency)
-        return((*_okPLL22393_GetOutputFrequency)(pll, n));
-    return(0.0);
+        return ((*_okPLL22393_GetOutputFrequency)(pll, n));
+    return (0.0);
 }
 
 okDLLEXPORT Bool DLL_ENTRY
 okPLL22393_IsOutputEnabled(okPLL22393_HANDLE pll, int n)
 {
     if (_okPLL22393_IsOutputEnabled)
-        return((*_okPLL22393_IsOutputEnabled)(pll, n));
-    return(FALSE);
+        return ((*_okPLL22393_IsOutputEnabled)(pll, n));
+    return (FALSE);
 }
 
 okDLLEXPORT Bool DLL_ENTRY
 okPLL22393_IsPLLEnabled(okPLL22393_HANDLE pll, int n)
 {
     if (_okPLL22393_IsPLLEnabled)
-        return((*_okPLL22393_IsPLLEnabled)(pll, n));
-    return(FALSE);
+        return ((*_okPLL22393_IsPLLEnabled)(pll, n));
+    return (FALSE);
 }
 
 okDLLEXPORT void DLL_ENTRY
@@ -1236,9 +1236,9 @@ okDLLEXPORT okPLL22150_HANDLE DLL_ENTRY
 okPLL22150_Construct()
 {
     if (_okPLL22150_Construct)
-        return((*_okPLL22150_Construct)());
+        return ((*_okPLL22150_Construct)());
 
-    return(NULL);
+    return (NULL);
 }
 
 okDLLEXPORT void DLL_ENTRY
@@ -1266,45 +1266,45 @@ okDLLEXPORT double DLL_ENTRY
 okPLL22150_GetReference(okPLL22150_HANDLE pll)
 {
     if (_okPLL22150_GetReference)
-        return((*_okPLL22150_GetReference)(pll));
+        return ((*_okPLL22150_GetReference)(pll));
 
-    return(0.0);
+    return (0.0);
 }
 
 okDLLEXPORT Bool DLL_ENTRY
 okPLL22150_SetVCOParameters(okPLL22150_HANDLE pll, int p, int q)
 {
     if (_okPLL22150_SetVCOParameters)
-        return((*_okPLL22150_SetVCOParameters)(pll, p, q));
+        return ((*_okPLL22150_SetVCOParameters)(pll, p, q));
 
-    return(FALSE);
+    return (FALSE);
 }
 
 okDLLEXPORT int DLL_ENTRY
 okPLL22150_GetVCOP(okPLL22150_HANDLE pll)
 {
     if (_okPLL22150_GetVCOP)
-        return((*_okPLL22150_GetVCOP)(pll));
+        return ((*_okPLL22150_GetVCOP)(pll));
 
-    return(0);
+    return (0);
 }
 
 okDLLEXPORT int DLL_ENTRY
 okPLL22150_GetVCOQ(okPLL22150_HANDLE pll)
 {
     if (_okPLL22150_GetVCOQ)
-        return((*_okPLL22150_GetVCOQ)(pll));
+        return ((*_okPLL22150_GetVCOQ)(pll));
 
-    return(0);
+    return (0);
 }
 
 okDLLEXPORT double DLL_ENTRY
 okPLL22150_GetVCOFrequency(okPLL22150_HANDLE pll)
 {
     if (_okPLL22150_GetVCOFrequency)
-        return((*_okPLL22150_GetVCOFrequency)(pll));
+        return ((*_okPLL22150_GetVCOFrequency)(pll));
 
-    return(0.0);
+    return (0.0);
 }
 
 okDLLEXPORT void DLL_ENTRY
@@ -1325,36 +1325,36 @@ okDLLEXPORT ok_DividerSource  DLL_ENTRY
 okPLL22150_GetDiv1Source(okPLL22150_HANDLE pll)
 {
     if (_okPLL22150_GetDiv1Source)
-        return((*_okPLL22150_GetDiv1Source)(pll));
+        return ((*_okPLL22150_GetDiv1Source)(pll));
 
-    return(ok_DivSrc_Ref);
+    return (ok_DivSrc_Ref);
 }
 
 okDLLEXPORT ok_DividerSource DLL_ENTRY
 okPLL22150_GetDiv2Source(okPLL22150_HANDLE pll)
 {
     if (_okPLL22150_GetDiv2Source)
-        return((*_okPLL22150_GetDiv2Source)(pll));
+        return ((*_okPLL22150_GetDiv2Source)(pll));
 
-    return(ok_DivSrc_Ref);
+    return (ok_DivSrc_Ref);
 }
 
 okDLLEXPORT int DLL_ENTRY
 okPLL22150_GetDiv1Divider(okPLL22150_HANDLE pll)
 {
     if (_okPLL22150_GetDiv1Divider)
-        return((*_okPLL22150_GetDiv1Divider)(pll));
+        return ((*_okPLL22150_GetDiv1Divider)(pll));
 
-    return(0);
+    return (0);
 }
 
 okDLLEXPORT int DLL_ENTRY
 okPLL22150_GetDiv2Divider(okPLL22150_HANDLE pll)
 {
     if (_okPLL22150_GetDiv2Divider)
-        return((*_okPLL22150_GetDiv2Divider)(pll));
+        return ((*_okPLL22150_GetDiv2Divider)(pll));
 
-    return(0);
+    return (0);
 }
 
 okDLLEXPORT void DLL_ENTRY
@@ -1375,27 +1375,27 @@ okDLLEXPORT ok_ClockSource_22150 DLL_ENTRY
 okPLL22150_GetOutputSource(okPLL22150_HANDLE pll, int output)
 {
     if (_okPLL22150_GetOutputSource)
-        return((*_okPLL22150_GetOutputSource)(pll, output));
+        return ((*_okPLL22150_GetOutputSource)(pll, output));
 
-    return(ok_ClkSrc22150_Ref);
+    return (ok_ClkSrc22150_Ref);
 }
 
 okDLLEXPORT double DLL_ENTRY
 okPLL22150_GetOutputFrequency(okPLL22150_HANDLE pll, int output)
 {
     if (_okPLL22150_GetOutputFrequency)
-        return((*_okPLL22150_GetOutputFrequency)(pll, output));
+        return ((*_okPLL22150_GetOutputFrequency)(pll, output));
 
-    return(0.0);
+    return (0.0);
 }
 
 okDLLEXPORT Bool DLL_ENTRY
 okPLL22150_IsOutputEnabled(okPLL22150_HANDLE pll, int output)
 {
     if (_okPLL22150_IsOutputEnabled)
-        return((*_okPLL22150_IsOutputEnabled)(pll, output));
+        return ((*_okPLL22150_IsOutputEnabled)(pll, output));
 
-    return(FALSE);
+    return (FALSE);
 }
 
 okDLLEXPORT void DLL_ENTRY
@@ -1420,9 +1420,9 @@ okDLLEXPORT okFrontPanel_HANDLE DLL_ENTRY
 okFrontPanel_Construct()
 {
     if (_okFrontPanel_Construct)
-        return((*_okFrontPanel_Construct)());
+        return ((*_okFrontPanel_Construct)());
 
-    return(NULL);
+    return (NULL);
 }
 
 
@@ -1438,9 +1438,9 @@ okDLLEXPORT int DLL_ENTRY
 okFrontPanel_GetHostInterfaceWidth(okFrontPanel_HANDLE hnd)
 {
     if (_okFrontPanel_GetHostInterfaceWidth)
-        return((*_okFrontPanel_GetHostInterfaceWidth)(hnd));
+        return ((*_okFrontPanel_GetHostInterfaceWidth)(hnd));
 
-    return(FALSE);
+    return (FALSE);
 }
 
 
@@ -1448,9 +1448,9 @@ okDLLEXPORT Bool DLL_ENTRY
 okFrontPanel_IsHighSpeed(okFrontPanel_HANDLE hnd)
 {
     if (_okFrontPanel_IsHighSpeed)
-        return((*_okFrontPanel_IsHighSpeed)(hnd));
+        return ((*_okFrontPanel_IsHighSpeed)(hnd));
 
-    return(FALSE);
+    return (FALSE);
 }
 
 
@@ -1458,9 +1458,9 @@ okDLLEXPORT ok_BoardModel DLL_ENTRY
 okFrontPanel_GetBoardModel(okFrontPanel_HANDLE hnd)
 {
     if (_okFrontPanel_GetBoardModel)
-        return((*_okFrontPanel_GetBoardModel)(hnd));
+        return ((*_okFrontPanel_GetBoardModel)(hnd));
 
-    return(ok_brdUnknown);
+    return (ok_brdUnknown);
 }
 
 
@@ -1476,9 +1476,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_WriteI2C(okFrontPanel_HANDLE hnd, const int addr, int length, unsigned char* data)
 {
     if (_okFrontPanel_WriteI2C)
-        return((*_okFrontPanel_WriteI2C)(hnd, addr, length, data));
+        return ((*_okFrontPanel_WriteI2C)(hnd, addr, length, data));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
@@ -1486,9 +1486,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_ReadI2C(okFrontPanel_HANDLE hnd, const int addr, int length, unsigned char* data)
 {
     if (_okFrontPanel_ReadI2C)
-        return((*_okFrontPanel_ReadI2C)(hnd, addr, length, data));
+        return ((*_okFrontPanel_ReadI2C)(hnd, addr, length, data));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
@@ -1496,9 +1496,9 @@ okDLLEXPORT int DLL_ENTRY
 okFrontPanel_GetDeviceCount(okFrontPanel_HANDLE hnd)
 {
     if (_okFrontPanel_GetDeviceCount)
-        return((*_okFrontPanel_GetDeviceCount)(hnd));
+        return ((*_okFrontPanel_GetDeviceCount)(hnd));
 
-    return(0);
+    return (0);
 }
 
 
@@ -1506,9 +1506,9 @@ okDLLEXPORT ok_BoardModel DLL_ENTRY
 okFrontPanel_GetDeviceListModel(okFrontPanel_HANDLE hnd, int num)
 {
     if (_okFrontPanel_GetDeviceListModel)
-        return((*_okFrontPanel_GetDeviceListModel)(hnd, num));
+        return ((*_okFrontPanel_GetDeviceListModel)(hnd, num));
 
-    return(ok_brdUnknown);
+    return (ok_brdUnknown);
 }
 
 
@@ -1524,18 +1524,18 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_OpenBySerial(okFrontPanel_HANDLE hnd, const char* serial)
 {
     if (_okFrontPanel_OpenBySerial)
-        return((*_okFrontPanel_OpenBySerial)(hnd, serial));
+        return ((*_okFrontPanel_OpenBySerial)(hnd, serial));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT Bool DLL_ENTRY
 okFrontPanel_IsOpen(okFrontPanel_HANDLE hnd)
 {
     if (_okFrontPanel_IsOpen)
-        return((*_okFrontPanel_IsOpen)(hnd));
+        return ((*_okFrontPanel_IsOpen)(hnd));
 
-    return(FALSE);
+    return (FALSE);
 }
 
 okDLLEXPORT void DLL_ENTRY
@@ -1549,9 +1549,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_SetBTPipePollingInterval(okFrontPanel_HANDLE hnd, int interval)
 {
     if (_okFrontPanel_SetBTPipePollingInterval)
-        return((*_okFrontPanel_SetBTPipePollingInterval)(hnd, interval));
+        return ((*_okFrontPanel_SetBTPipePollingInterval)(hnd, interval));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT void DLL_ENTRY
@@ -1565,36 +1565,36 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_GetDeviceInfo(okFrontPanel_HANDLE hnd, okTDeviceInfo* info)
 {
     if (_okFrontPanel_GetDeviceInfo)
-        return((*_okFrontPanel_GetDeviceInfo)(hnd, info));
+        return ((*_okFrontPanel_GetDeviceInfo)(hnd, info));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT int DLL_ENTRY
 okFrontPanel_GetDeviceMajorVersion(okFrontPanel_HANDLE hnd)
 {
     if (_okFrontPanel_GetDeviceMajorVersion)
-        return((*_okFrontPanel_GetDeviceMajorVersion)(hnd));
+        return ((*_okFrontPanel_GetDeviceMajorVersion)(hnd));
 
-    return(0);
+    return (0);
 }
 
 okDLLEXPORT int DLL_ENTRY
 okFrontPanel_GetDeviceMinorVersion(okFrontPanel_HANDLE hnd)
 {
     if (_okFrontPanel_GetDeviceMinorVersion)
-        return((*_okFrontPanel_GetDeviceMinorVersion)(hnd));
+        return ((*_okFrontPanel_GetDeviceMinorVersion)(hnd));
 
-    return(0);
+    return (0);
 }
 
 okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_ResetFPGA(okFrontPanel_HANDLE hnd)
 {
     if (_okFrontPanel_ResetFPGA)
-        return((*_okFrontPanel_ResetFPGA)(hnd));
+        return ((*_okFrontPanel_ResetFPGA)(hnd));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT void DLL_ENTRY
@@ -1622,117 +1622,117 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_ConfigureFPGA(okFrontPanel_HANDLE hnd, const char* strFilename)
 {
     if (_okFrontPanel_ConfigureFPGA)
-        return((*_okFrontPanel_ConfigureFPGA)(hnd, strFilename));
+        return ((*_okFrontPanel_ConfigureFPGA)(hnd, strFilename));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_ConfigureFPGAFromMemory(okFrontPanel_HANDLE hnd, unsigned char* data, unsigned long length)
 {
     if (_okFrontPanel_ConfigureFPGAFromMemory)
-        return((*_okFrontPanel_ConfigureFPGAFromMemory)(hnd, data, length));
+        return ((*_okFrontPanel_ConfigureFPGAFromMemory)(hnd, data, length));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_GetPLL22150Configuration(okFrontPanel_HANDLE hnd, okPLL22150_HANDLE pll)
 {
     if (_okFrontPanel_GetPLL22150Configuration)
-        return((*_okFrontPanel_GetPLL22150Configuration)(hnd, pll));
+        return ((*_okFrontPanel_GetPLL22150Configuration)(hnd, pll));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_SetPLL22150Configuration(okFrontPanel_HANDLE hnd, okPLL22150_HANDLE pll)
 {
     if (_okFrontPanel_SetPLL22150Configuration)
-        return((*_okFrontPanel_SetPLL22150Configuration)(hnd, pll));
+        return ((*_okFrontPanel_SetPLL22150Configuration)(hnd, pll));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_GetEepromPLL22150Configuration(okFrontPanel_HANDLE hnd, okPLL22150_HANDLE pll)
 {
     if (_okFrontPanel_GetEepromPLL22150Configuration)
-        return((*_okFrontPanel_GetEepromPLL22150Configuration)(hnd, pll));
+        return ((*_okFrontPanel_GetEepromPLL22150Configuration)(hnd, pll));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_SetEepromPLL22150Configuration(okFrontPanel_HANDLE hnd, okPLL22150_HANDLE pll)
 {
     if (_okFrontPanel_SetEepromPLL22150Configuration)
-        return((*_okFrontPanel_SetEepromPLL22150Configuration)(hnd, pll));
+        return ((*_okFrontPanel_SetEepromPLL22150Configuration)(hnd, pll));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_GetPLL22393Configuration(okFrontPanel_HANDLE hnd, okPLL22393_HANDLE pll)
 {
     if (_okFrontPanel_GetPLL22393Configuration)
-        return((*_okFrontPanel_GetPLL22393Configuration)(hnd, pll));
+        return ((*_okFrontPanel_GetPLL22393Configuration)(hnd, pll));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_SetPLL22393Configuration(okFrontPanel_HANDLE hnd, okPLL22393_HANDLE pll)
 {
     if (_okFrontPanel_SetPLL22393Configuration)
-        return((*_okFrontPanel_SetPLL22393Configuration)(hnd, pll));
+        return ((*_okFrontPanel_SetPLL22393Configuration)(hnd, pll));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_GetEepromPLL22393Configuration(okFrontPanel_HANDLE hnd, okPLL22393_HANDLE pll)
 {
     if (_okFrontPanel_GetEepromPLL22393Configuration)
-        return((*_okFrontPanel_GetEepromPLL22393Configuration)(hnd, pll));
+        return ((*_okFrontPanel_GetEepromPLL22393Configuration)(hnd, pll));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_SetEepromPLL22393Configuration(okFrontPanel_HANDLE hnd, okPLL22393_HANDLE pll)
 {
     if (_okFrontPanel_SetEepromPLL22393Configuration)
-        return((*_okFrontPanel_SetEepromPLL22393Configuration)(hnd, pll));
+        return ((*_okFrontPanel_SetEepromPLL22393Configuration)(hnd, pll));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_LoadDefaultPLLConfiguration(okFrontPanel_HANDLE hnd)
 {
     if (_okFrontPanel_LoadDefaultPLLConfiguration)
-        return((*_okFrontPanel_LoadDefaultPLLConfiguration)(hnd));
+        return ((*_okFrontPanel_LoadDefaultPLLConfiguration)(hnd));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT Bool DLL_ENTRY
 okFrontPanel_IsFrontPanelEnabled(okFrontPanel_HANDLE hnd)
 {
     if (_okFrontPanel_IsFrontPanelEnabled)
-        return((*_okFrontPanel_IsFrontPanelEnabled)(hnd));
+        return ((*_okFrontPanel_IsFrontPanelEnabled)(hnd));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT Bool DLL_ENTRY
 okFrontPanel_IsFrontPanel3Supported(okFrontPanel_HANDLE hnd)
 {
     if (_okFrontPanel_IsFrontPanel3Supported)
-        return((*_okFrontPanel_IsFrontPanel3Supported)(hnd));
+        return ((*_okFrontPanel_IsFrontPanel3Supported)(hnd));
 
-    return(FALSE);
+    return (FALSE);
 }
 
 okDLLEXPORT void DLL_ENTRY
@@ -1746,9 +1746,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_SetWireInValue(okFrontPanel_HANDLE hnd, int ep, unsigned long val, unsigned long mask)
 {
     if (_okFrontPanel_SetWireInValue)
-        return((*_okFrontPanel_SetWireInValue)(hnd, ep, val, mask));
+        return ((*_okFrontPanel_SetWireInValue)(hnd, ep, val, mask));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT void DLL_ENTRY
@@ -1762,18 +1762,18 @@ okDLLEXPORT unsigned long DLL_ENTRY
 okFrontPanel_GetWireOutValue(okFrontPanel_HANDLE hnd, int epAddr)
 {
     if (_okFrontPanel_GetWireOutValue)
-        return((*_okFrontPanel_GetWireOutValue)(hnd, epAddr));
+        return ((*_okFrontPanel_GetWireOutValue)(hnd, epAddr));
 
-    return(0);
+    return (0);
 }
 
 okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_ActivateTriggerIn(okFrontPanel_HANDLE hnd, int epAddr, int bit)
 {
     if (_okFrontPanel_ActivateTriggerIn)
-        return((*_okFrontPanel_ActivateTriggerIn)(hnd, epAddr, bit));
+        return ((*_okFrontPanel_ActivateTriggerIn)(hnd, epAddr, bit));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 okDLLEXPORT void DLL_ENTRY
@@ -1787,63 +1787,63 @@ okDLLEXPORT Bool DLL_ENTRY
 okFrontPanel_IsTriggered(okFrontPanel_HANDLE hnd, int epAddr, unsigned long mask)
 {
     if (_okFrontPanel_IsTriggered)
-        return((*_okFrontPanel_IsTriggered)(hnd, epAddr, mask));
+        return ((*_okFrontPanel_IsTriggered)(hnd, epAddr, mask));
 
-    return(FALSE);
+    return (FALSE);
 }
 
 okDLLEXPORT long DLL_ENTRY
 okFrontPanel_GetLastTransferLength(okFrontPanel_HANDLE hnd)
 {
     if (_okFrontPanel_GetLastTransferLength)
-        return((*_okFrontPanel_GetLastTransferLength)(hnd));
+        return ((*_okFrontPanel_GetLastTransferLength)(hnd));
 
-    return(0);
+    return (0);
 }
 
 okDLLEXPORT long DLL_ENTRY
 okFrontPanel_WriteToPipeIn(okFrontPanel_HANDLE hnd, int epAddr, long length, unsigned char* data)
 {
     if (_okFrontPanel_WriteToPipeIn)
-        return((*_okFrontPanel_WriteToPipeIn)(hnd, epAddr, length, data));
+        return ((*_okFrontPanel_WriteToPipeIn)(hnd, epAddr, length, data));
 
-    return(0);
+    return (0);
 }
 
 okDLLEXPORT long DLL_ENTRY
 okFrontPanel_WriteToBlockPipeIn(okFrontPanel_HANDLE hnd, int epAddr, int blocksize, long length, unsigned char* data)
 {
     if (_okFrontPanel_WriteToBlockPipeIn)
-        return((*_okFrontPanel_WriteToBlockPipeIn)(hnd, epAddr, blocksize, length, data));
+        return ((*_okFrontPanel_WriteToBlockPipeIn)(hnd, epAddr, blocksize, length, data));
 
-    return(0);
+    return (0);
 }
 
 okDLLEXPORT long DLL_ENTRY
 okFrontPanel_ReadFromPipeOut(okFrontPanel_HANDLE hnd, int epAddr, long length, unsigned char* data)
 {
     if (_okFrontPanel_ReadFromPipeOut)
-        return((*_okFrontPanel_ReadFromPipeOut)(hnd, epAddr, length, data));
+        return ((*_okFrontPanel_ReadFromPipeOut)(hnd, epAddr, length, data));
 
-    return(0);
+    return (0);
 }
 
 okDLLEXPORT long DLL_ENTRY
 okFrontPanel_ReadFromBlockPipeOut(okFrontPanel_HANDLE hnd, int epAddr, int blocksize, long length, unsigned char* data)
 {
     if (_okFrontPanel_ReadFromBlockPipeOut)
-        return((*_okFrontPanel_ReadFromBlockPipeOut)(hnd, epAddr, blocksize, length, data));
+        return ((*_okFrontPanel_ReadFromBlockPipeOut)(hnd, epAddr, blocksize, length, data));
 
-    return(0);
+    return (0);
 }
 
 okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_FlashEraseSector(okFrontPanel_HANDLE hnd, UINT32 address)
 {
     if (_okFrontPanel_FlashEraseSector)
-        return((*_okFrontPanel_FlashEraseSector)(hnd, address));
+        return ((*_okFrontPanel_FlashEraseSector)(hnd, address));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
@@ -1851,9 +1851,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_FlashWrite(okFrontPanel_HANDLE hnd, UINT32 address, UINT32 length, const UINT8* buf)
 {
     if (_okFrontPanel_FlashWrite)
-        return((*_okFrontPanel_FlashWrite)(hnd, address, length, buf));
+        return ((*_okFrontPanel_FlashWrite)(hnd, address, length, buf));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
@@ -1861,9 +1861,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_FlashRead(okFrontPanel_HANDLE hnd, UINT32 address, UINT32 length, UINT8* buf)
 {
     if (_okFrontPanel_FlashRead)
-        return((*_okFrontPanel_FlashRead)(hnd, address, length, buf));
+        return ((*_okFrontPanel_FlashRead)(hnd, address, length, buf));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
@@ -1871,9 +1871,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_GetFPGABootResetProfile(okFrontPanel_HANDLE hnd, okTFPGAResetProfile* profile)
 {
     if (_okFrontPanel_GetFPGABootResetProfile)
-        return((*_okFrontPanel_GetFPGABootResetProfile)(hnd, profile));
+        return ((*_okFrontPanel_GetFPGABootResetProfile)(hnd, profile));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
@@ -1881,9 +1881,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_GetFPGAJTAGResetProfile(okFrontPanel_HANDLE hnd, okTFPGAResetProfile* profile)
 {
     if (_okFrontPanel_GetFPGAJTAGResetProfile)
-        return((*_okFrontPanel_GetFPGAJTAGResetProfile)(hnd, profile));
+        return ((*_okFrontPanel_GetFPGAJTAGResetProfile)(hnd, profile));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
@@ -1891,9 +1891,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_SetFPGABootResetProfile(okFrontPanel_HANDLE hnd, okTFPGAResetProfile* profile)
 {
     if (_okFrontPanel_SetFPGABootResetProfile)
-        return((*_okFrontPanel_SetFPGABootResetProfile)(hnd, profile));
+        return ((*_okFrontPanel_SetFPGABootResetProfile)(hnd, profile));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
@@ -1901,9 +1901,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_SetFPGAJTAGResetProfile(okFrontPanel_HANDLE hnd, okTFPGAResetProfile* profile)
 {
     if (_okFrontPanel_SetFPGAJTAGResetProfile)
-        return((*_okFrontPanel_SetFPGAJTAGResetProfile)(hnd, profile));
+        return ((*_okFrontPanel_SetFPGAJTAGResetProfile)(hnd, profile));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
@@ -1911,9 +1911,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_ReadRegister(okFrontPanel_HANDLE hnd, UINT32 addr, UINT32* data)
 {
     if (_okFrontPanel_ReadRegister)
-        return((*_okFrontPanel_ReadRegister)(hnd, addr, data));
+        return ((*_okFrontPanel_ReadRegister)(hnd, addr, data));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
@@ -1921,9 +1921,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_ReadRegisterSet(okFrontPanel_HANDLE hnd, okTRegisterSet* set)
 {
     if (_okFrontPanel_ReadRegisterSet)
-        return((*_okFrontPanel_ReadRegisterSet)(hnd, set));
+        return ((*_okFrontPanel_ReadRegisterSet)(hnd, set));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
@@ -1931,9 +1931,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_WriteRegister(okFrontPanel_HANDLE hnd, UINT32 addr, UINT32 data)
 {
     if (_okFrontPanel_WriteRegister)
-        return((*_okFrontPanel_WriteRegister)(hnd, addr, data));
+        return ((*_okFrontPanel_WriteRegister)(hnd, addr, data));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
@@ -1941,9 +1941,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_WriteRegisterSet(okFrontPanel_HANDLE hnd, okTRegisterSet* set)
 {
     if (_okFrontPanel_WriteRegisterSet)
-        return((*_okFrontPanel_WriteRegisterSet)(hnd, set));
+        return ((*_okFrontPanel_WriteRegisterSet)(hnd, set));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
@@ -1951,9 +1951,9 @@ okDLLEXPORT ok_ErrorCode DLL_ENTRY
 okFrontPanel_GetWireInValue(okFrontPanel_HANDLE hnd, int epAddr, UINT32* val)
 {
     if (_okFrontPanel_GetWireInValue)
-        return((*_okFrontPanel_GetWireInValue)(hnd, epAddr, val));
+        return ((*_okFrontPanel_GetWireInValue)(hnd, epAddr, val));
 
-    return(ok_UnsupportedFeature);
+    return (ok_UnsupportedFeature);
 }
 
 
diff --git a/Source/Processors/DataThreads/rhythm-api/okFrontPanelDLL.h b/Source/Processors/DataThreads/rhythm-api/okFrontPanelDLL.h
index deefab371f9f672447a223472483d3820c1791e8..b616769acde5b32611f281b3b0a9ad830b37d185 100755
--- a/Source/Processors/DataThreads/rhythm-api/okFrontPanelDLL.h
+++ b/Source/Processors/DataThreads/rhythm-api/okFrontPanelDLL.h
@@ -45,10 +45,10 @@ typedef void (* DLL_EP)(void);
 extern "C" {
 #endif // __cplusplus
 
-    typedef void* okPLL22150_HANDLE;
-    typedef void* okPLL22393_HANDLE;
-    typedef void* okFrontPanel_HANDLE;
-    typedef int Bool;
+typedef void* okPLL22150_HANDLE;
+typedef void* okPLL22393_HANDLE;
+typedef void* okFrontPanel_HANDLE;
+typedef int Bool;
 
 #define MAX_SERIALNUMBER_LENGTH      10       // 10 characters + Does NOT include termination NULL.
 #define MAX_DEVICEID_LENGTH          32       // 32 characters + Does NOT include termination NULL.
@@ -59,90 +59,90 @@ extern "C" {
 #define FALSE   0
 #endif
 
-    typedef enum
-    {
-        ok_ClkSrc22150_Ref=0,
-        ok_ClkSrc22150_Div1ByN=1,
-        ok_ClkSrc22150_Div1By2=2,
-        ok_ClkSrc22150_Div1By3=3,
-        ok_ClkSrc22150_Div2ByN=4,
-        ok_ClkSrc22150_Div2By2=5,
-        ok_ClkSrc22150_Div2By4=6
-    } ok_ClockSource_22150;
-
-    typedef enum
-    {
-        ok_ClkSrc22393_Ref=0,
-        ok_ClkSrc22393_PLL0_0=2,
-        ok_ClkSrc22393_PLL0_180=3,
-        ok_ClkSrc22393_PLL1_0=4,
-        ok_ClkSrc22393_PLL1_180=5,
-        ok_ClkSrc22393_PLL2_0=6,
-        ok_ClkSrc22393_PLL2_180=7
-    } ok_ClockSource_22393;
-
-    typedef enum
-    {
-        ok_DivSrc_Ref = 0,
-        ok_DivSrc_VCO = 1
-    } ok_DividerSource;
-
-    typedef enum
-    {
-        ok_brdUnknown = 0,
-        ok_brdXEM3001v1 = 1,
-        ok_brdXEM3001v2 = 2,
-        ok_brdXEM3010 = 3,
-        ok_brdXEM3005 = 4,
-        ok_brdXEM3001CL = 5,
-        ok_brdXEM3020 = 6,
-        ok_brdXEM3050 = 7,
-        ok_brdXEM9002 = 8,
-        ok_brdXEM3001RB = 9,
-        ok_brdXEM5010 = 10,
-        ok_brdXEM6110LX45 = 11,
-        ok_brdXEM6110LX150 = 15,
-        ok_brdXEM6001 = 12,
-        ok_brdXEM6010LX45 = 13,
-        ok_brdXEM6010LX150 = 14,
-        ok_brdXEM6006LX9 = 16,
-        ok_brdXEM6006LX16 = 17,
-        ok_brdXEM6006LX25 = 18,
-        ok_brdXEM5010LX110 = 19,
-        ok_brdZEM4310=20,
-        ok_brdXEM6310LX45=21,
-        ok_brdXEM6310LX150=22,
-        ok_brdXEM6110v2LX45=23,
-        ok_brdXEM6110v2LX150=24,
-        ok_brdXEM6002LX9=25,
-        ok_brdXEM6310MTLX45T=26,
-        ok_brdXEM6320LX130T=27
-    } ok_BoardModel;
-
-    typedef enum
-    {
-        ok_NoError                    = 0,
-        ok_Failed                     = -1,
-        ok_Timeout                    = -2,
-        ok_DoneNotHigh                = -3,
-        ok_TransferError              = -4,
-        ok_CommunicationError         = -5,
-        ok_InvalidBitstream           = -6,
-        ok_FileError                  = -7,
-        ok_DeviceNotOpen              = -8,
-        ok_InvalidEndpoint            = -9,
-        ok_InvalidBlockSize           = -10,
-        ok_I2CRestrictedAddress       = -11,
-        ok_I2CBitError                = -12,
-        ok_I2CNack                    = -13,
-        ok_I2CUnknownStatus           = -14,
-        ok_UnsupportedFeature         = -15,
-        ok_FIFOUnderflow              = -16,
-        ok_FIFOOverflow               = -17,
-        ok_DataAlignmentError         = -18,
-        ok_InvalidResetProfile        = -19,
-        ok_InvalidParameter           = -20
-    } ok_ErrorCode;
+typedef enum
+{
+    ok_ClkSrc22150_Ref=0,
+    ok_ClkSrc22150_Div1ByN=1,
+    ok_ClkSrc22150_Div1By2=2,
+    ok_ClkSrc22150_Div1By3=3,
+    ok_ClkSrc22150_Div2ByN=4,
+    ok_ClkSrc22150_Div2By2=5,
+    ok_ClkSrc22150_Div2By4=6
+} ok_ClockSource_22150;
+
+typedef enum
+{
+    ok_ClkSrc22393_Ref=0,
+    ok_ClkSrc22393_PLL0_0=2,
+    ok_ClkSrc22393_PLL0_180=3,
+    ok_ClkSrc22393_PLL1_0=4,
+    ok_ClkSrc22393_PLL1_180=5,
+    ok_ClkSrc22393_PLL2_0=6,
+    ok_ClkSrc22393_PLL2_180=7
+} ok_ClockSource_22393;
+
+typedef enum
+{
+    ok_DivSrc_Ref = 0,
+    ok_DivSrc_VCO = 1
+} ok_DividerSource;
+
+typedef enum
+{
+    ok_brdUnknown = 0,
+    ok_brdXEM3001v1 = 1,
+    ok_brdXEM3001v2 = 2,
+    ok_brdXEM3010 = 3,
+    ok_brdXEM3005 = 4,
+    ok_brdXEM3001CL = 5,
+    ok_brdXEM3020 = 6,
+    ok_brdXEM3050 = 7,
+    ok_brdXEM9002 = 8,
+    ok_brdXEM3001RB = 9,
+    ok_brdXEM5010 = 10,
+    ok_brdXEM6110LX45 = 11,
+    ok_brdXEM6110LX150 = 15,
+    ok_brdXEM6001 = 12,
+    ok_brdXEM6010LX45 = 13,
+    ok_brdXEM6010LX150 = 14,
+    ok_brdXEM6006LX9 = 16,
+    ok_brdXEM6006LX16 = 17,
+    ok_brdXEM6006LX25 = 18,
+    ok_brdXEM5010LX110 = 19,
+    ok_brdZEM4310=20,
+    ok_brdXEM6310LX45=21,
+    ok_brdXEM6310LX150=22,
+    ok_brdXEM6110v2LX45=23,
+    ok_brdXEM6110v2LX150=24,
+    ok_brdXEM6002LX9=25,
+    ok_brdXEM6310MTLX45T=26,
+    ok_brdXEM6320LX130T=27
+} ok_BoardModel;
+
+typedef enum
+{
+    ok_NoError                    = 0,
+    ok_Failed                     = -1,
+    ok_Timeout                    = -2,
+    ok_DoneNotHigh                = -3,
+    ok_TransferError              = -4,
+    ok_CommunicationError         = -5,
+    ok_InvalidBitstream           = -6,
+    ok_FileError                  = -7,
+    ok_DeviceNotOpen              = -8,
+    ok_InvalidEndpoint            = -9,
+    ok_InvalidBlockSize           = -10,
+    ok_I2CRestrictedAddress       = -11,
+    ok_I2CBitError                = -12,
+    ok_I2CNack                    = -13,
+    ok_I2CUnknownStatus           = -14,
+    ok_UnsupportedFeature         = -15,
+    ok_FIFOUnderflow              = -16,
+    ok_FIFOOverflow               = -17,
+    ok_DataAlignmentError         = -18,
+    ok_InvalidResetProfile        = -19,
+    ok_InvalidParameter           = -20
+} ok_ErrorCode;
 
 #ifndef FRONTPANELDLL_EXPORTS
 
@@ -150,19 +150,19 @@ extern "C" {
 #define OK_MAX_SERIALNUMBER_LENGTH          (11)     // 10-byte content + NULL termination
 #define OK_MAX_BOARD_MODEL_STRING_LENGTH    (128)
 
-    // ok_USBSpeed types
+// ok_USBSpeed types
 #define OK_USBSPEED_UNKNOWN                 (0)
 #define OK_USBSPEED_FULL                    (1)
 #define OK_USBSPEED_HIGH                    (2)
 #define OK_USBSPEED_SUPER                   (3)
 
-    // ok_Interface types
+// ok_Interface types
 #define OK_INTERFACE_UNKNOWN                (0)
 #define OK_INTERFACE_USB2                   (1)
 #define OK_INTERFACE_PCIE                   (2)
 #define OK_INTERFACE_USB3                   (3)
 
-    // ok_Product types
+// ok_Product types
 #define OK_PRODUCT_UNKNOWN                  (0)
 #define OK_PRODUCT_XEM3001V1                (1)
 #define OK_PRODUCT_XEM3001V2                (2)
@@ -193,242 +193,242 @@ extern "C" {
 #define OK_PRODUCT_XEM6320LX130T            (27)
 
 
-    typedef struct okRegisterEntry
-    {
-        UINT32   address;
-        UINT32   data;
-    } okTRegisterEntry;
+typedef struct okRegisterEntry
+{
+    UINT32   address;
+    UINT32   data;
+} okTRegisterEntry;
 
 
 #define okREGISTER_SET_ENTRIES       (64)
-    typedef struct okFPGARegisterSet
-    {
-        UINT32            count;
-        okTRegisterEntry  entries[okREGISTER_SET_ENTRIES];
-    } okTRegisterSet;
-
-
-    typedef struct okTriggerEntry
-    {
-        UINT32   address;
-        UINT32   mask;
-    } okTTriggerEntry;
-
-
-    typedef struct okFPGAResetProfile
-    {
-        // Magic number indicating the profile is valid.  (4 byte = 0xBE097C3D)
-        UINT32                     magic;
-
-        // Location of the configuration file (Flash boot).  (4 bytes)
-        UINT32                     configFileLocation;
-
-        // Length of the configuration file.  (4 bytes)
-        UINT32                     configFileLength;
-
-        // Number of microseconds to wait after DONE goes high before
-        // starting the reset profile.  (4 bytes)
-        UINT32                     doneWaitUS;
-
-        // Number of microseconds to wait after wires are updated
-        // before deasserting logic RESET.  (4 bytes)
-        UINT32                     resetWaitUS;
-
-        // Number of microseconds to wait after RESET is deasserted
-        // before loading registers.  (4 bytes)
-        UINT32                     registerWaitUS;
-
-        // Future expansion  (112 bytes)
-        UINT32                     padBytes1[28];
-
-        // Initial values of WireIns.  These are loaded prior to
-        // deasserting logic RESET.  (32*4 = 128 bytes)
-        UINT32                     wireInValues[32];
-
-        // Number of valid Register Entries (4 bytes)
-        UINT32                     registerEntryCount;
+typedef struct okFPGARegisterSet
+{
+    UINT32            count;
+    okTRegisterEntry  entries[okREGISTER_SET_ENTRIES];
+} okTRegisterSet;
+
+
+typedef struct okTriggerEntry
+{
+    UINT32   address;
+    UINT32   mask;
+} okTTriggerEntry;
+
+
+typedef struct okFPGAResetProfile
+{
+    // Magic number indicating the profile is valid.  (4 byte = 0xBE097C3D)
+    UINT32                     magic;
+
+    // Location of the configuration file (Flash boot).  (4 bytes)
+    UINT32                     configFileLocation;
+
+    // Length of the configuration file.  (4 bytes)
+    UINT32                     configFileLength;
+
+    // Number of microseconds to wait after DONE goes high before
+    // starting the reset profile.  (4 bytes)
+    UINT32                     doneWaitUS;
+
+    // Number of microseconds to wait after wires are updated
+    // before deasserting logic RESET.  (4 bytes)
+    UINT32                     resetWaitUS;
+
+    // Number of microseconds to wait after RESET is deasserted
+    // before loading registers.  (4 bytes)
+    UINT32                     registerWaitUS;
+
+    // Future expansion  (112 bytes)
+    UINT32                     padBytes1[28];
+
+    // Initial values of WireIns.  These are loaded prior to
+    // deasserting logic RESET.  (32*4 = 128 bytes)
+    UINT32                     wireInValues[32];
+
+    // Number of valid Register Entries (4 bytes)
+    UINT32                     registerEntryCount;
+
+    // Initial register loads.  (256*8 = 2048 bytes)
+    okTRegisterEntry           registerEntries[256];
+
+    // Number of valid Trigger Entries (4 bytes)
+    UINT32                     triggerEntryCount;
+
+    // Initial trigger assertions.  These are performed last.
+    // (32*8 = 256 bytes)
+    okTTriggerEntry            triggerEntries[32];
+
+    // Padding to a 4096-byte size for future expansion
+    UINT8                      padBytes2[1520];
+} okTFPGAResetProfile;
+
+
+// Describes the layout of an available Flash memory on the device
+typedef struct
+{
+    UINT32             sectorCount;
+    UINT32             sectorSize;
+    UINT32             pageSize;
+    UINT32             minUserSector;
+    UINT32             maxUserSector;
+} okTFlashLayout;
+
+
+typedef struct
+{
+    char            deviceID[OK_MAX_DEVICEID_LENGTH];
+    char            serialNumber[OK_MAX_SERIALNUMBER_LENGTH];
+    char            productName[OK_MAX_BOARD_MODEL_STRING_LENGTH];
+    int             productID;
+    int             deviceInterface;
+    int             usbSpeed;
+    int             deviceMajorVersion;
+    int             deviceMinorVersion;
+    int             hostInterfaceMajorVersion;
+    int             hostInterfaceMinorVersion;
+    bool            isPLL22150Supported;
+    bool            isPLL22393Supported;
+    bool            isFrontPanelEnabled;
+    int             wireWidth;
+    int             triggerWidth;
+    int             pipeWidth;
+    int             registerAddressWidth;
+    int             registerDataWidth;
+
+    okTFlashLayout  flashSystem;
+    okTFlashLayout  flashFPGA;
+} okTDeviceInfo;
 
-        // Initial register loads.  (256*8 = 2048 bytes)
-        okTRegisterEntry           registerEntries[256];
-
-        // Number of valid Trigger Entries (4 bytes)
-        UINT32                     triggerEntryCount;
-
-        // Initial trigger assertions.  These are performed last.
-        // (32*8 = 256 bytes)
-        okTTriggerEntry            triggerEntries[32];
-
-        // Padding to a 4096-byte size for future expansion
-        UINT8                      padBytes2[1520];
-    } okTFPGAResetProfile;
+#endif
 
+//
+// Define the LoadLib and FreeLib methods for the IMPORT side.
+//
+#ifndef FRONTPANELDLL_EXPORTS
+Bool okFrontPanelDLL_LoadLib(okFP_dll_pchar libname);
+void okFrontPanelDLL_FreeLib(void);
+#endif
 
-    // Describes the layout of an available Flash memory on the device
-    typedef struct
-    {
-        UINT32             sectorCount;
-        UINT32             sectorSize;
-        UINT32             pageSize;
-        UINT32             minUserSector;
-        UINT32             maxUserSector;
-    } okTFlashLayout;
+//
+// General
+//
+okDLLEXPORT void DLL_ENTRY okFrontPanelDLL_GetVersion(char* date, char* time);
 
+//
+// okPLL22393
+//
+okDLLEXPORT okPLL22393_HANDLE DLL_ENTRY okPLL22393_Construct();
+okDLLEXPORT void DLL_ENTRY okPLL22393_Destruct(okPLL22393_HANDLE pll);
+okDLLEXPORT void DLL_ENTRY okPLL22393_SetCrystalLoad(okPLL22393_HANDLE pll, double capload);
+okDLLEXPORT void DLL_ENTRY okPLL22393_SetReference(okPLL22393_HANDLE pll, double freq);
+okDLLEXPORT double DLL_ENTRY okPLL22393_GetReference(okPLL22393_HANDLE pll);
+okDLLEXPORT Bool DLL_ENTRY okPLL22393_SetPLLParameters(okPLL22393_HANDLE pll, int n, int p, int q, Bool enable);
+okDLLEXPORT Bool DLL_ENTRY okPLL22393_SetPLLLF(okPLL22393_HANDLE pll, int n, int lf);
+okDLLEXPORT Bool DLL_ENTRY okPLL22393_SetOutputDivider(okPLL22393_HANDLE pll, int n, int div);
+okDLLEXPORT Bool DLL_ENTRY okPLL22393_SetOutputSource(okPLL22393_HANDLE pll, int n, ok_ClockSource_22393 clksrc);
+okDLLEXPORT void DLL_ENTRY okPLL22393_SetOutputEnable(okPLL22393_HANDLE pll, int n, Bool enable);
+okDLLEXPORT int DLL_ENTRY okPLL22393_GetPLLP(okPLL22393_HANDLE pll, int n);
+okDLLEXPORT int DLL_ENTRY okPLL22393_GetPLLQ(okPLL22393_HANDLE pll, int n);
+okDLLEXPORT double DLL_ENTRY okPLL22393_GetPLLFrequency(okPLL22393_HANDLE pll, int n);
+okDLLEXPORT int DLL_ENTRY okPLL22393_GetOutputDivider(okPLL22393_HANDLE pll, int n);
+okDLLEXPORT ok_ClockSource_22393 DLL_ENTRY okPLL22393_GetOutputSource(okPLL22393_HANDLE pll, int n);
+okDLLEXPORT double DLL_ENTRY okPLL22393_GetOutputFrequency(okPLL22393_HANDLE pll, int n);
+okDLLEXPORT Bool DLL_ENTRY okPLL22393_IsOutputEnabled(okPLL22393_HANDLE pll, int n);
+okDLLEXPORT Bool DLL_ENTRY okPLL22393_IsPLLEnabled(okPLL22393_HANDLE pll, int n);
+okDLLEXPORT void DLL_ENTRY okPLL22393_InitFromProgrammingInfo(okPLL22393_HANDLE pll, unsigned char* buf);
+okDLLEXPORT void DLL_ENTRY okPLL22393_GetProgrammingInfo(okPLL22393_HANDLE pll, unsigned char* buf);
 
-    typedef struct
-    {
-        char            deviceID[OK_MAX_DEVICEID_LENGTH];
-        char            serialNumber[OK_MAX_SERIALNUMBER_LENGTH];
-        char            productName[OK_MAX_BOARD_MODEL_STRING_LENGTH];
-        int             productID;
-        int             deviceInterface;
-        int             usbSpeed;
-        int             deviceMajorVersion;
-        int             deviceMinorVersion;
-        int             hostInterfaceMajorVersion;
-        int             hostInterfaceMinorVersion;
-        bool            isPLL22150Supported;
-        bool            isPLL22393Supported;
-        bool            isFrontPanelEnabled;
-        int             wireWidth;
-        int             triggerWidth;
-        int             pipeWidth;
-        int             registerAddressWidth;
-        int             registerDataWidth;
-
-        okTFlashLayout  flashSystem;
-        okTFlashLayout  flashFPGA;
-    } okTDeviceInfo;
 
-#endif
+//
+// okPLL22150
+//
+okDLLEXPORT okPLL22150_HANDLE DLL_ENTRY okPLL22150_Construct();
+okDLLEXPORT void DLL_ENTRY okPLL22150_Destruct(okPLL22150_HANDLE pll);
+okDLLEXPORT void DLL_ENTRY okPLL22150_SetCrystalLoad(okPLL22150_HANDLE pll, double capload);
+okDLLEXPORT void DLL_ENTRY okPLL22150_SetReference(okPLL22150_HANDLE pll, double freq, Bool extosc);
+okDLLEXPORT double DLL_ENTRY okPLL22150_GetReference(okPLL22150_HANDLE pll);
+okDLLEXPORT Bool DLL_ENTRY okPLL22150_SetVCOParameters(okPLL22150_HANDLE pll, int p, int q);
+okDLLEXPORT int DLL_ENTRY okPLL22150_GetVCOP(okPLL22150_HANDLE pll);
+okDLLEXPORT int DLL_ENTRY okPLL22150_GetVCOQ(okPLL22150_HANDLE pll);
+okDLLEXPORT double DLL_ENTRY okPLL22150_GetVCOFrequency(okPLL22150_HANDLE pll);
+okDLLEXPORT void DLL_ENTRY okPLL22150_SetDiv1(okPLL22150_HANDLE pll, ok_DividerSource divsrc, int n);
+okDLLEXPORT void DLL_ENTRY okPLL22150_SetDiv2(okPLL22150_HANDLE pll, ok_DividerSource divsrc, int n);
+okDLLEXPORT ok_DividerSource DLL_ENTRY okPLL22150_GetDiv1Source(okPLL22150_HANDLE pll);
+okDLLEXPORT ok_DividerSource DLL_ENTRY okPLL22150_GetDiv2Source(okPLL22150_HANDLE pll);
+okDLLEXPORT int DLL_ENTRY okPLL22150_GetDiv1Divider(okPLL22150_HANDLE pll);
+okDLLEXPORT int DLL_ENTRY okPLL22150_GetDiv2Divider(okPLL22150_HANDLE pll);
+okDLLEXPORT void DLL_ENTRY okPLL22150_SetOutputSource(okPLL22150_HANDLE pll, int output, ok_ClockSource_22150 clksrc);
+okDLLEXPORT void DLL_ENTRY okPLL22150_SetOutputEnable(okPLL22150_HANDLE pll, int output, Bool enable);
+okDLLEXPORT ok_ClockSource_22150 DLL_ENTRY okPLL22150_GetOutputSource(okPLL22150_HANDLE pll, int output);
+okDLLEXPORT double DLL_ENTRY okPLL22150_GetOutputFrequency(okPLL22150_HANDLE pll, int output);
+okDLLEXPORT Bool DLL_ENTRY okPLL22150_IsOutputEnabled(okPLL22150_HANDLE pll, int output);
+okDLLEXPORT void DLL_ENTRY okPLL22150_InitFromProgrammingInfo(okPLL22150_HANDLE pll, unsigned char* buf);
+okDLLEXPORT void DLL_ENTRY okPLL22150_GetProgrammingInfo(okPLL22150_HANDLE pll, unsigned char* buf);
 
-    //
-    // Define the LoadLib and FreeLib methods for the IMPORT side.
-    //
-#ifndef FRONTPANELDLL_EXPORTS
-    Bool okFrontPanelDLL_LoadLib(okFP_dll_pchar libname);
-    void okFrontPanelDLL_FreeLib(void);
-#endif
 
-    //
-    // General
-    //
-    okDLLEXPORT void DLL_ENTRY okFrontPanelDLL_GetVersion(char* date, char* time);
-
-    //
-    // okPLL22393
-    //
-    okDLLEXPORT okPLL22393_HANDLE DLL_ENTRY okPLL22393_Construct();
-    okDLLEXPORT void DLL_ENTRY okPLL22393_Destruct(okPLL22393_HANDLE pll);
-    okDLLEXPORT void DLL_ENTRY okPLL22393_SetCrystalLoad(okPLL22393_HANDLE pll, double capload);
-    okDLLEXPORT void DLL_ENTRY okPLL22393_SetReference(okPLL22393_HANDLE pll, double freq);
-    okDLLEXPORT double DLL_ENTRY okPLL22393_GetReference(okPLL22393_HANDLE pll);
-    okDLLEXPORT Bool DLL_ENTRY okPLL22393_SetPLLParameters(okPLL22393_HANDLE pll, int n, int p, int q, Bool enable);
-    okDLLEXPORT Bool DLL_ENTRY okPLL22393_SetPLLLF(okPLL22393_HANDLE pll, int n, int lf);
-    okDLLEXPORT Bool DLL_ENTRY okPLL22393_SetOutputDivider(okPLL22393_HANDLE pll, int n, int div);
-    okDLLEXPORT Bool DLL_ENTRY okPLL22393_SetOutputSource(okPLL22393_HANDLE pll, int n, ok_ClockSource_22393 clksrc);
-    okDLLEXPORT void DLL_ENTRY okPLL22393_SetOutputEnable(okPLL22393_HANDLE pll, int n, Bool enable);
-    okDLLEXPORT int DLL_ENTRY okPLL22393_GetPLLP(okPLL22393_HANDLE pll, int n);
-    okDLLEXPORT int DLL_ENTRY okPLL22393_GetPLLQ(okPLL22393_HANDLE pll, int n);
-    okDLLEXPORT double DLL_ENTRY okPLL22393_GetPLLFrequency(okPLL22393_HANDLE pll, int n);
-    okDLLEXPORT int DLL_ENTRY okPLL22393_GetOutputDivider(okPLL22393_HANDLE pll, int n);
-    okDLLEXPORT ok_ClockSource_22393 DLL_ENTRY okPLL22393_GetOutputSource(okPLL22393_HANDLE pll, int n);
-    okDLLEXPORT double DLL_ENTRY okPLL22393_GetOutputFrequency(okPLL22393_HANDLE pll, int n);
-    okDLLEXPORT Bool DLL_ENTRY okPLL22393_IsOutputEnabled(okPLL22393_HANDLE pll, int n);
-    okDLLEXPORT Bool DLL_ENTRY okPLL22393_IsPLLEnabled(okPLL22393_HANDLE pll, int n);
-    okDLLEXPORT void DLL_ENTRY okPLL22393_InitFromProgrammingInfo(okPLL22393_HANDLE pll, unsigned char* buf);
-    okDLLEXPORT void DLL_ENTRY okPLL22393_GetProgrammingInfo(okPLL22393_HANDLE pll, unsigned char* buf);
-
-
-    //
-    // okPLL22150
-    //
-    okDLLEXPORT okPLL22150_HANDLE DLL_ENTRY okPLL22150_Construct();
-    okDLLEXPORT void DLL_ENTRY okPLL22150_Destruct(okPLL22150_HANDLE pll);
-    okDLLEXPORT void DLL_ENTRY okPLL22150_SetCrystalLoad(okPLL22150_HANDLE pll, double capload);
-    okDLLEXPORT void DLL_ENTRY okPLL22150_SetReference(okPLL22150_HANDLE pll, double freq, Bool extosc);
-    okDLLEXPORT double DLL_ENTRY okPLL22150_GetReference(okPLL22150_HANDLE pll);
-    okDLLEXPORT Bool DLL_ENTRY okPLL22150_SetVCOParameters(okPLL22150_HANDLE pll, int p, int q);
-    okDLLEXPORT int DLL_ENTRY okPLL22150_GetVCOP(okPLL22150_HANDLE pll);
-    okDLLEXPORT int DLL_ENTRY okPLL22150_GetVCOQ(okPLL22150_HANDLE pll);
-    okDLLEXPORT double DLL_ENTRY okPLL22150_GetVCOFrequency(okPLL22150_HANDLE pll);
-    okDLLEXPORT void DLL_ENTRY okPLL22150_SetDiv1(okPLL22150_HANDLE pll, ok_DividerSource divsrc, int n);
-    okDLLEXPORT void DLL_ENTRY okPLL22150_SetDiv2(okPLL22150_HANDLE pll, ok_DividerSource divsrc, int n);
-    okDLLEXPORT ok_DividerSource DLL_ENTRY okPLL22150_GetDiv1Source(okPLL22150_HANDLE pll);
-    okDLLEXPORT ok_DividerSource DLL_ENTRY okPLL22150_GetDiv2Source(okPLL22150_HANDLE pll);
-    okDLLEXPORT int DLL_ENTRY okPLL22150_GetDiv1Divider(okPLL22150_HANDLE pll);
-    okDLLEXPORT int DLL_ENTRY okPLL22150_GetDiv2Divider(okPLL22150_HANDLE pll);
-    okDLLEXPORT void DLL_ENTRY okPLL22150_SetOutputSource(okPLL22150_HANDLE pll, int output, ok_ClockSource_22150 clksrc);
-    okDLLEXPORT void DLL_ENTRY okPLL22150_SetOutputEnable(okPLL22150_HANDLE pll, int output, Bool enable);
-    okDLLEXPORT ok_ClockSource_22150 DLL_ENTRY okPLL22150_GetOutputSource(okPLL22150_HANDLE pll, int output);
-    okDLLEXPORT double DLL_ENTRY okPLL22150_GetOutputFrequency(okPLL22150_HANDLE pll, int output);
-    okDLLEXPORT Bool DLL_ENTRY okPLL22150_IsOutputEnabled(okPLL22150_HANDLE pll, int output);
-    okDLLEXPORT void DLL_ENTRY okPLL22150_InitFromProgrammingInfo(okPLL22150_HANDLE pll, unsigned char* buf);
-    okDLLEXPORT void DLL_ENTRY okPLL22150_GetProgrammingInfo(okPLL22150_HANDLE pll, unsigned char* buf);
-
-
-    //
-    // okFrontPanel
-    //
-    okDLLEXPORT okFrontPanel_HANDLE DLL_ENTRY okFrontPanel_Construct();
-    okDLLEXPORT void DLL_ENTRY okFrontPanel_Destruct(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_WriteI2C(okFrontPanel_HANDLE hnd, const int addr, int length, unsigned char* data);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ReadI2C(okFrontPanel_HANDLE hnd, const int addr, int length, unsigned char* data);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_FlashEraseSector(okFrontPanel_HANDLE hnd, UINT32 address);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_FlashWrite(okFrontPanel_HANDLE hnd, UINT32 address, UINT32 length, const UINT8* buf);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_FlashRead(okFrontPanel_HANDLE hnd, UINT32 address, UINT32 length, UINT8* buf);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetFPGABootResetProfile(okFrontPanel_HANDLE hnd, okTFPGAResetProfile* profile);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetFPGAJTAGResetProfile(okFrontPanel_HANDLE hnd, okTFPGAResetProfile* profile);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetFPGABootResetProfile(okFrontPanel_HANDLE hnd, okTFPGAResetProfile* profile);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetFPGAJTAGResetProfile(okFrontPanel_HANDLE hnd, okTFPGAResetProfile* profile);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ReadRegister(okFrontPanel_HANDLE hnd, UINT32 addr, UINT32* data);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ReadRegisterSet(okFrontPanel_HANDLE hnd, okTRegisterSet* set);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_WriteRegister(okFrontPanel_HANDLE hnd, UINT32 addr, UINT32 data);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_WriteRegisterSet(okFrontPanel_HANDLE hnd, okTRegisterSet* set);
-    okDLLEXPORT int DLL_ENTRY okFrontPanel_GetHostInterfaceWidth(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT Bool DLL_ENTRY okFrontPanel_IsHighSpeed(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT ok_BoardModel DLL_ENTRY okFrontPanel_GetBoardModel(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT void DLL_ENTRY okFrontPanel_GetBoardModelString(okFrontPanel_HANDLE hnd, ok_BoardModel m, char* buf);
-    okDLLEXPORT int DLL_ENTRY okFrontPanel_GetDeviceCount(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT ok_BoardModel DLL_ENTRY okFrontPanel_GetDeviceListModel(okFrontPanel_HANDLE hnd, int num);
-    okDLLEXPORT void DLL_ENTRY okFrontPanel_GetDeviceListSerial(okFrontPanel_HANDLE hnd, int num, char* buf);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_OpenBySerial(okFrontPanel_HANDLE hnd, const char* serial);
-    okDLLEXPORT Bool DLL_ENTRY okFrontPanel_IsOpen(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT void DLL_ENTRY okFrontPanel_EnableAsynchronousTransfers(okFrontPanel_HANDLE hnd, Bool enable);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetBTPipePollingInterval(okFrontPanel_HANDLE hnd, int interval);
-    okDLLEXPORT void DLL_ENTRY okFrontPanel_SetTimeout(okFrontPanel_HANDLE hnd, int timeout);
-    okDLLEXPORT int DLL_ENTRY okFrontPanel_GetDeviceMajorVersion(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT int DLL_ENTRY okFrontPanel_GetDeviceMinorVersion(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ResetFPGA(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT void DLL_ENTRY okFrontPanel_GetSerialNumber(okFrontPanel_HANDLE hnd, char* buf);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetDeviceInfo(okFrontPanel_HANDLE hnd, okTDeviceInfo* info);
-    okDLLEXPORT void DLL_ENTRY okFrontPanel_GetDeviceID(okFrontPanel_HANDLE hnd, char* buf);
-    okDLLEXPORT void DLL_ENTRY okFrontPanel_SetDeviceID(okFrontPanel_HANDLE hnd, const char* strID);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ConfigureFPGA(okFrontPanel_HANDLE hnd, const char* strFilename);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ConfigureFPGAFromMemory(okFrontPanel_HANDLE hnd, unsigned char* data, unsigned long length);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetPLL22150Configuration(okFrontPanel_HANDLE hnd, okPLL22150_HANDLE pll);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetPLL22150Configuration(okFrontPanel_HANDLE hnd, okPLL22150_HANDLE pll);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetEepromPLL22150Configuration(okFrontPanel_HANDLE hnd, okPLL22150_HANDLE pll);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetEepromPLL22150Configuration(okFrontPanel_HANDLE hnd, okPLL22150_HANDLE pll);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetPLL22393Configuration(okFrontPanel_HANDLE hnd, okPLL22393_HANDLE pll);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetPLL22393Configuration(okFrontPanel_HANDLE hnd, okPLL22393_HANDLE pll);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetEepromPLL22393Configuration(okFrontPanel_HANDLE hnd, okPLL22393_HANDLE pll);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetEepromPLL22393Configuration(okFrontPanel_HANDLE hnd, okPLL22393_HANDLE pll);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_LoadDefaultPLLConfiguration(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT Bool DLL_ENTRY okFrontPanel_IsFrontPanelEnabled(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT Bool DLL_ENTRY okFrontPanel_IsFrontPanel3Supported(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT void DLL_ENTRY okFrontPanel_UpdateWireIns(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetWireInValue(okFrontPanel_HANDLE hnd, int epAddr, UINT32* val);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetWireInValue(okFrontPanel_HANDLE hnd, int ep, unsigned long val, unsigned long mask);
-    okDLLEXPORT void DLL_ENTRY okFrontPanel_UpdateWireOuts(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT unsigned long DLL_ENTRY okFrontPanel_GetWireOutValue(okFrontPanel_HANDLE hnd, int epAddr);
-    okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ActivateTriggerIn(okFrontPanel_HANDLE hnd, int epAddr, int bit);
-    okDLLEXPORT void DLL_ENTRY okFrontPanel_UpdateTriggerOuts(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT Bool DLL_ENTRY okFrontPanel_IsTriggered(okFrontPanel_HANDLE hnd, int epAddr, unsigned long mask);
-    okDLLEXPORT long DLL_ENTRY okFrontPanel_GetLastTransferLength(okFrontPanel_HANDLE hnd);
-    okDLLEXPORT long DLL_ENTRY okFrontPanel_WriteToPipeIn(okFrontPanel_HANDLE hnd, int epAddr, long length, unsigned char* data);
-    okDLLEXPORT long DLL_ENTRY okFrontPanel_ReadFromPipeOut(okFrontPanel_HANDLE hnd, int epAddr, long length, unsigned char* data);
-    okDLLEXPORT long DLL_ENTRY okFrontPanel_WriteToBlockPipeIn(okFrontPanel_HANDLE hnd, int epAddr, int blockSize, long length, unsigned char* data);
-    okDLLEXPORT long DLL_ENTRY okFrontPanel_ReadFromBlockPipeOut(okFrontPanel_HANDLE hnd, int epAddr, int blockSize, long length, unsigned char* data);
+//
+// okFrontPanel
+//
+okDLLEXPORT okFrontPanel_HANDLE DLL_ENTRY okFrontPanel_Construct();
+okDLLEXPORT void DLL_ENTRY okFrontPanel_Destruct(okFrontPanel_HANDLE hnd);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_WriteI2C(okFrontPanel_HANDLE hnd, const int addr, int length, unsigned char* data);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ReadI2C(okFrontPanel_HANDLE hnd, const int addr, int length, unsigned char* data);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_FlashEraseSector(okFrontPanel_HANDLE hnd, UINT32 address);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_FlashWrite(okFrontPanel_HANDLE hnd, UINT32 address, UINT32 length, const UINT8* buf);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_FlashRead(okFrontPanel_HANDLE hnd, UINT32 address, UINT32 length, UINT8* buf);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetFPGABootResetProfile(okFrontPanel_HANDLE hnd, okTFPGAResetProfile* profile);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetFPGAJTAGResetProfile(okFrontPanel_HANDLE hnd, okTFPGAResetProfile* profile);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetFPGABootResetProfile(okFrontPanel_HANDLE hnd, okTFPGAResetProfile* profile);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetFPGAJTAGResetProfile(okFrontPanel_HANDLE hnd, okTFPGAResetProfile* profile);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ReadRegister(okFrontPanel_HANDLE hnd, UINT32 addr, UINT32* data);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ReadRegisterSet(okFrontPanel_HANDLE hnd, okTRegisterSet* set);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_WriteRegister(okFrontPanel_HANDLE hnd, UINT32 addr, UINT32 data);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_WriteRegisterSet(okFrontPanel_HANDLE hnd, okTRegisterSet* set);
+okDLLEXPORT int DLL_ENTRY okFrontPanel_GetHostInterfaceWidth(okFrontPanel_HANDLE hnd);
+okDLLEXPORT Bool DLL_ENTRY okFrontPanel_IsHighSpeed(okFrontPanel_HANDLE hnd);
+okDLLEXPORT ok_BoardModel DLL_ENTRY okFrontPanel_GetBoardModel(okFrontPanel_HANDLE hnd);
+okDLLEXPORT void DLL_ENTRY okFrontPanel_GetBoardModelString(okFrontPanel_HANDLE hnd, ok_BoardModel m, char* buf);
+okDLLEXPORT int DLL_ENTRY okFrontPanel_GetDeviceCount(okFrontPanel_HANDLE hnd);
+okDLLEXPORT ok_BoardModel DLL_ENTRY okFrontPanel_GetDeviceListModel(okFrontPanel_HANDLE hnd, int num);
+okDLLEXPORT void DLL_ENTRY okFrontPanel_GetDeviceListSerial(okFrontPanel_HANDLE hnd, int num, char* buf);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_OpenBySerial(okFrontPanel_HANDLE hnd, const char* serial);
+okDLLEXPORT Bool DLL_ENTRY okFrontPanel_IsOpen(okFrontPanel_HANDLE hnd);
+okDLLEXPORT void DLL_ENTRY okFrontPanel_EnableAsynchronousTransfers(okFrontPanel_HANDLE hnd, Bool enable);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetBTPipePollingInterval(okFrontPanel_HANDLE hnd, int interval);
+okDLLEXPORT void DLL_ENTRY okFrontPanel_SetTimeout(okFrontPanel_HANDLE hnd, int timeout);
+okDLLEXPORT int DLL_ENTRY okFrontPanel_GetDeviceMajorVersion(okFrontPanel_HANDLE hnd);
+okDLLEXPORT int DLL_ENTRY okFrontPanel_GetDeviceMinorVersion(okFrontPanel_HANDLE hnd);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ResetFPGA(okFrontPanel_HANDLE hnd);
+okDLLEXPORT void DLL_ENTRY okFrontPanel_GetSerialNumber(okFrontPanel_HANDLE hnd, char* buf);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetDeviceInfo(okFrontPanel_HANDLE hnd, okTDeviceInfo* info);
+okDLLEXPORT void DLL_ENTRY okFrontPanel_GetDeviceID(okFrontPanel_HANDLE hnd, char* buf);
+okDLLEXPORT void DLL_ENTRY okFrontPanel_SetDeviceID(okFrontPanel_HANDLE hnd, const char* strID);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ConfigureFPGA(okFrontPanel_HANDLE hnd, const char* strFilename);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ConfigureFPGAFromMemory(okFrontPanel_HANDLE hnd, unsigned char* data, unsigned long length);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetPLL22150Configuration(okFrontPanel_HANDLE hnd, okPLL22150_HANDLE pll);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetPLL22150Configuration(okFrontPanel_HANDLE hnd, okPLL22150_HANDLE pll);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetEepromPLL22150Configuration(okFrontPanel_HANDLE hnd, okPLL22150_HANDLE pll);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetEepromPLL22150Configuration(okFrontPanel_HANDLE hnd, okPLL22150_HANDLE pll);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetPLL22393Configuration(okFrontPanel_HANDLE hnd, okPLL22393_HANDLE pll);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetPLL22393Configuration(okFrontPanel_HANDLE hnd, okPLL22393_HANDLE pll);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetEepromPLL22393Configuration(okFrontPanel_HANDLE hnd, okPLL22393_HANDLE pll);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetEepromPLL22393Configuration(okFrontPanel_HANDLE hnd, okPLL22393_HANDLE pll);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_LoadDefaultPLLConfiguration(okFrontPanel_HANDLE hnd);
+okDLLEXPORT Bool DLL_ENTRY okFrontPanel_IsFrontPanelEnabled(okFrontPanel_HANDLE hnd);
+okDLLEXPORT Bool DLL_ENTRY okFrontPanel_IsFrontPanel3Supported(okFrontPanel_HANDLE hnd);
+okDLLEXPORT void DLL_ENTRY okFrontPanel_UpdateWireIns(okFrontPanel_HANDLE hnd);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_GetWireInValue(okFrontPanel_HANDLE hnd, int epAddr, UINT32* val);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_SetWireInValue(okFrontPanel_HANDLE hnd, int ep, unsigned long val, unsigned long mask);
+okDLLEXPORT void DLL_ENTRY okFrontPanel_UpdateWireOuts(okFrontPanel_HANDLE hnd);
+okDLLEXPORT unsigned long DLL_ENTRY okFrontPanel_GetWireOutValue(okFrontPanel_HANDLE hnd, int epAddr);
+okDLLEXPORT ok_ErrorCode DLL_ENTRY okFrontPanel_ActivateTriggerIn(okFrontPanel_HANDLE hnd, int epAddr, int bit);
+okDLLEXPORT void DLL_ENTRY okFrontPanel_UpdateTriggerOuts(okFrontPanel_HANDLE hnd);
+okDLLEXPORT Bool DLL_ENTRY okFrontPanel_IsTriggered(okFrontPanel_HANDLE hnd, int epAddr, unsigned long mask);
+okDLLEXPORT long DLL_ENTRY okFrontPanel_GetLastTransferLength(okFrontPanel_HANDLE hnd);
+okDLLEXPORT long DLL_ENTRY okFrontPanel_WriteToPipeIn(okFrontPanel_HANDLE hnd, int epAddr, long length, unsigned char* data);
+okDLLEXPORT long DLL_ENTRY okFrontPanel_ReadFromPipeOut(okFrontPanel_HANDLE hnd, int epAddr, long length, unsigned char* data);
+okDLLEXPORT long DLL_ENTRY okFrontPanel_WriteToBlockPipeIn(okFrontPanel_HANDLE hnd, int epAddr, int blockSize, long length, unsigned char* data);
+okDLLEXPORT long DLL_ENTRY okFrontPanel_ReadFromBlockPipeOut(okFrontPanel_HANDLE hnd, int epAddr, int blockSize, long length, unsigned char* data);
 
 
 #ifdef __cplusplus
diff --git a/Source/Processors/DataThreads/rhythm-api/rhd2000datablock.cpp b/Source/Processors/DataThreads/rhythm-api/rhd2000datablock.cpp
index 449ca4731a291eaf8658a79b4015156aabade610..d22a4ba36a9b557c50e5843ce5514714d7f21493 100755
--- a/Source/Processors/DataThreads/rhythm-api/rhd2000datablock.cpp
+++ b/Source/Processors/DataThreads/rhythm-api/rhd2000datablock.cpp
@@ -42,19 +42,19 @@ Rhd2000DataBlock::Rhd2000DataBlock(int numDataStreams)
 }
 
 // Allocates memory for a 1-D array of integers.
-void Rhd2000DataBlock::allocateIntArray1D(vector<int> &array1D, int xSize)
+void Rhd2000DataBlock::allocateIntArray1D(vector<int>& array1D, int xSize)
 {
     array1D.resize(xSize);
 }
 
 // Allocates memory for a 1-D array of unsigned integers.
-void Rhd2000DataBlock::allocateUIntArray1D(vector<unsigned int> &array1D, int xSize)
+void Rhd2000DataBlock::allocateUIntArray1D(vector<unsigned int>& array1D, int xSize)
 {
     array1D.resize(xSize);
 }
 
 // Allocates memory for a 2-D array of integers.
-void Rhd2000DataBlock::allocateIntArray2D(vector<vector<int> > & array2D, int xSize, int ySize)
+void Rhd2000DataBlock::allocateIntArray2D(vector<vector<int> >& array2D, int xSize, int ySize)
 {
     int i;
 
@@ -64,7 +64,7 @@ void Rhd2000DataBlock::allocateIntArray2D(vector<vector<int> > & array2D, int xS
 }
 
 // Allocates memory for a 3-D array of integers.
-void Rhd2000DataBlock::allocateIntArray3D(vector<vector<vector<int> > > &array3D, int xSize, int ySize, int zSize)
+void Rhd2000DataBlock::allocateIntArray3D(vector<vector<vector<int> > >& array3D, int xSize, int ySize, int zSize)
 {
     int i, j;
 
diff --git a/Source/Processors/DataThreads/rhythm-api/rhd2000datablock.h b/Source/Processors/DataThreads/rhythm-api/rhd2000datablock.h
index d27a2c3eede0b4785c0b110e874b6d707bc0b48f..121d43e92d9b67016f7009ef7350fb216eaec76a 100755
--- a/Source/Processors/DataThreads/rhythm-api/rhd2000datablock.h
+++ b/Source/Processors/DataThreads/rhythm-api/rhd2000datablock.h
@@ -46,10 +46,10 @@ public:
     void write(ofstream& saveOut, int numDataStreams) const;
 
 private:
-    void allocateIntArray3D(vector<vector<vector<int> > > &array3D, int xSize, int ySize, int zSize);
-    void allocateIntArray2D(vector<vector<int> > &array2D, int xSize, int ySize);
-    void allocateIntArray1D(vector<int> &array1D, int xSize);
-    void allocateUIntArray1D(vector<unsigned int> &array1D, int xSize);
+    void allocateIntArray3D(vector<vector<vector<int> > >& array3D, int xSize, int ySize, int zSize);
+    void allocateIntArray2D(vector<vector<int> >& array2D, int xSize, int ySize);
+    void allocateIntArray1D(vector<int>& array1D, int xSize);
+    void allocateUIntArray1D(vector<unsigned int>& array1D, int xSize);
 
     void writeWordLittleEndian(ofstream& outputStream, int dataWord) const;
 
diff --git a/Source/Processors/DataThreads/rhythm-api/rhd2000evalboard.cpp b/Source/Processors/DataThreads/rhythm-api/rhd2000evalboard.cpp
index 62bc4faf1d91f26b5ff27534694734c8a45c5843..54e5e702162843a8658edfa10d7c826d488b00d7 100755
--- a/Source/Processors/DataThreads/rhythm-api/rhd2000evalboard.cpp
+++ b/Source/Processors/DataThreads/rhythm-api/rhd2000evalboard.cpp
@@ -41,7 +41,7 @@ Rhd2000EvalBoard::Rhd2000EvalBoard()
     int i;
     sampleRate = SampleRate30000Hz; // Rhythm FPGA boots up with 30.0 kS/s/channel sampling rate
     numDataStreams = 0;
-	dev = 0; //nullptr;
+    dev = 0; //nullptr;
 
     for (i = 0; i < MAX_NUM_DATA_STREAMS; ++i)
     {
@@ -52,7 +52,7 @@ Rhd2000EvalBoard::Rhd2000EvalBoard()
 //Destructor: Deletes the device to avoid memory leak
 Rhd2000EvalBoard::~Rhd2000EvalBoard()
 {
-	if (dev != 0) delete dev;
+    if (dev != 0) delete dev;
 }
 
 // Find an Opal Kelly XEM6010-LX45 board attached to a USB port and open it.
@@ -73,7 +73,7 @@ int Rhd2000EvalBoard::open(const char* libname)
     okFrontPanelDLL_GetVersion(dll_date, dll_time);
     cout << endl << "FrontPanel DLL loaded.  Built: " << dll_date << "  " << dll_time << endl;
 
-	if (dev != 0) delete dev; //Avoid memory leaks if open is called twice.
+    if (dev != 0) delete dev; //Avoid memory leaks if open is called twice.
 
     dev = new okCFrontPanel;
 
@@ -103,7 +103,7 @@ int Rhd2000EvalBoard::open(const char* libname)
     if (dev->OpenBySerial(serialNumber) != okCFrontPanel::NoError)
     {
         delete dev;
-		dev = 0; //nullptr;
+        dev = 0; //nullptr;
         cerr << "Device could not be opened.  Is one connected?" << endl;
         return -2;
     }
@@ -132,28 +132,28 @@ bool Rhd2000EvalBoard::uploadFpgaBitfile(string filename)
             break;
         case okCFrontPanel::DeviceNotOpen:
             cerr << "FPGA configuration failed: Device not open." << endl;
-            return(false);
+            return (false);
         case okCFrontPanel::FileError:
             cerr << "FPGA configuration failed: Cannot find configuration file." << endl;
-            return(false);
+            return (false);
         case okCFrontPanel::InvalidBitstream:
             cerr << "FPGA configuration failed: Bitstream is not properly formatted." << endl;
-            return(false);
+            return (false);
         case okCFrontPanel::DoneNotHigh:
             cerr << "FPGA configuration failed: FPGA DONE signal did not assert after configuration." << endl;
-            return(false);
+            return (false);
         case okCFrontPanel::TransferError:
             cerr << "FPGA configuration failed: USB error occurred during download." << endl;
-            return(false);
+            return (false);
         case okCFrontPanel::CommunicationError:
             cerr << "FPGA configuration failed: Communication error with firmware." << endl;
-            return(false);
+            return (false);
         case okCFrontPanel::UnsupportedFeature:
             cerr << "FPGA configuration failed: Unsupported feature." << endl;
-            return(false);
+            return (false);
         default:
             cerr << "FPGA configuration failed: Unknown error." << endl;
-            return(false);
+            return (false);
     }
 
     // Check for Opal Kelly FrontPanel support in the FPGA configuration.
@@ -161,8 +161,8 @@ bool Rhd2000EvalBoard::uploadFpgaBitfile(string filename)
     {
         cerr << "Opal Kelly FrontPanel support is not enabled in this FPGA configuration." << endl;
         delete dev;
-		dev = 0; //nullptr;
-        return(false);
+        dev = 0; //nullptr;
+        return (false);
     }
 
     int boardId, boardVersion;
@@ -173,7 +173,7 @@ bool Rhd2000EvalBoard::uploadFpgaBitfile(string filename)
     if (boardId != RHYTHM_BOARD_ID)
     {
         cerr << "FPGA configuration does not support Rhythm.  Incorrect board ID: " << boardId << endl;
-        return(false);
+        return (false);
     }
     else
     {
@@ -181,7 +181,7 @@ bool Rhd2000EvalBoard::uploadFpgaBitfile(string filename)
              boardVersion << endl << endl;
     }
 
-    return(true);
+    return (true);
 }
 
 
@@ -406,7 +406,7 @@ bool Rhd2000EvalBoard::setSampleRate(AmplifierSampleRate newSampleRate)
             D = 25;
             break;
         default:
-            return(false);
+            return (false);
     }
 
     sampleRate = newSampleRate;
@@ -422,7 +422,7 @@ bool Rhd2000EvalBoard::setSampleRate(AmplifierSampleRate newSampleRate)
     // Wait for DataClkLocked = 1 before allowing data acquisition to continue
     while (isDataClockLocked() == false) {}
 
-    return(true);
+    return (true);
 }
 
 // Returns the current per-channel sampling rate (in Hz) as a floating-point number.
@@ -492,7 +492,7 @@ Rhd2000EvalBoard::AmplifierSampleRate Rhd2000EvalBoard::getSampleRateEnum() cons
 }
 
 // Print a command list to the console in readable form.
-void Rhd2000EvalBoard::printCommandList(const vector<int> &commandList) const
+void Rhd2000EvalBoard::printCommandList(const vector<int>& commandList) const
 {
     unsigned int i;
     int cmd, channel, reg, data;
@@ -543,7 +543,7 @@ void Rhd2000EvalBoard::printCommandList(const vector<int> &commandList) const
 
 // Upload an auxiliary command list to a particular command slot (AuxCmd1, AuxCmd2, or AuxCmd3) and RAM bank (0-15)
 // on the FPGA.
-void Rhd2000EvalBoard::uploadCommandList(const vector<int> &commandList, AuxCmdSlot auxCommandSlot, int bank)
+void Rhd2000EvalBoard::uploadCommandList(const vector<int>& commandList, AuxCmdSlot auxCommandSlot, int bank)
 {
     unsigned int i;
 
@@ -1232,7 +1232,7 @@ bool Rhd2000EvalBoard::readDataBlock(Rhd2000DataBlock* dataBlock)
 
 // Reads a certain number of USB data blocks, if the specified number is available, and appends them
 // to queue.  Returns true if data blocks were available.
-bool Rhd2000EvalBoard::readDataBlocks(int numBlocks, queue<Rhd2000DataBlock> &dataQueue)
+bool Rhd2000EvalBoard::readDataBlocks(int numBlocks, queue<Rhd2000DataBlock>& dataQueue)
 {
     unsigned int numWordsToRead, numBytesToRead;
     int i;
@@ -1269,7 +1269,7 @@ bool Rhd2000EvalBoard::readDataBlocks(int numBlocks, queue<Rhd2000DataBlock> &da
 
 // Writes the contents of a data block queue (dataQueue) to a binary output stream (saveOut).
 // Returns the number of data blocks written.
-int Rhd2000EvalBoard::queueToFile(queue<Rhd2000DataBlock> &dataQueue, ofstream& saveOut)
+int Rhd2000EvalBoard::queueToFile(queue<Rhd2000DataBlock>& dataQueue, ofstream& saveOut)
 {
     int count = 0;
 
@@ -1289,61 +1289,61 @@ string Rhd2000EvalBoard::opalKellyModelName(int model) const
     switch (model)
     {
         case OK_PRODUCT_XEM3001V1:
-            return("XEM3001V1");
+            return ("XEM3001V1");
         case OK_PRODUCT_XEM3001V2:
-            return("XEM3001V2");
+            return ("XEM3001V2");
         case OK_PRODUCT_XEM3010:
-            return("XEM3010");
+            return ("XEM3010");
         case OK_PRODUCT_XEM3005:
-            return("XEM3005");
+            return ("XEM3005");
         case OK_PRODUCT_XEM3001CL:
-            return("XEM3001CL");
+            return ("XEM3001CL");
         case OK_PRODUCT_XEM3020:
-            return("XEM3020");
+            return ("XEM3020");
         case OK_PRODUCT_XEM3050:
-            return("XEM3050");
+            return ("XEM3050");
         case OK_PRODUCT_XEM9002:
-            return("XEM9002");
+            return ("XEM9002");
         case OK_PRODUCT_XEM3001RB:
-            return("XEM3001RB");
+            return ("XEM3001RB");
         case OK_PRODUCT_XEM5010:
-            return("XEM5010");
+            return ("XEM5010");
         case OK_PRODUCT_XEM6110LX45:
-            return("XEM6110LX45");
+            return ("XEM6110LX45");
         case OK_PRODUCT_XEM6001:
-            return("XEM6001");
+            return ("XEM6001");
         case OK_PRODUCT_XEM6010LX45:
-            return("XEM6010LX45");
+            return ("XEM6010LX45");
         case OK_PRODUCT_XEM6010LX150:
-            return("XEM6010LX150");
+            return ("XEM6010LX150");
         case OK_PRODUCT_XEM6110LX150:
-            return("XEM6110LX150");
+            return ("XEM6110LX150");
         case OK_PRODUCT_XEM6006LX9:
-            return("XEM6006LX9");
+            return ("XEM6006LX9");
         case OK_PRODUCT_XEM6006LX16:
-            return("XEM6006LX16");
+            return ("XEM6006LX16");
         case OK_PRODUCT_XEM6006LX25:
-            return("XEM6006LX25");
+            return ("XEM6006LX25");
         case OK_PRODUCT_XEM5010LX110:
-            return("XEM5010LX110");
+            return ("XEM5010LX110");
         case OK_PRODUCT_ZEM4310:
-            return("ZEM4310");
+            return ("ZEM4310");
         case OK_PRODUCT_XEM6310LX45:
-            return("XEM6310LX45");
+            return ("XEM6310LX45");
         case OK_PRODUCT_XEM6310LX150:
-            return("XEM6310LX150");
+            return ("XEM6310LX150");
         case OK_PRODUCT_XEM6110V2LX45:
-            return("XEM6110V2LX45");
+            return ("XEM6110V2LX45");
         case OK_PRODUCT_XEM6110V2LX150:
-            return("XEM6110V2LX150");
+            return ("XEM6110V2LX150");
         case OK_PRODUCT_XEM6002LX9:
-            return("XEM6002LX9");
+            return ("XEM6002LX9");
         case OK_PRODUCT_XEM6310MTLX45:
-            return("XEM6310MTLX45");
+            return ("XEM6310MTLX45");
         case OK_PRODUCT_XEM6320LX130T:
-            return("XEM6320LX130T");
+            return ("XEM6320LX130T");
         default:
-            return("UNKNOWN");
+            return ("UNKNOWN");
     }
 }
 
diff --git a/Source/Processors/DataThreads/rhythm-api/rhd2000evalboard.h b/Source/Processors/DataThreads/rhythm-api/rhd2000evalboard.h
index 3191973279549b6ce0925646c44f3cf5c141fb59..5bc2749fa8ba775848e42cdf5c1d1223d30efb87 100755
--- a/Source/Processors/DataThreads/rhythm-api/rhd2000evalboard.h
+++ b/Source/Processors/DataThreads/rhythm-api/rhd2000evalboard.h
@@ -38,7 +38,7 @@ class Rhd2000EvalBoard
 
 public:
     Rhd2000EvalBoard();
-	~Rhd2000EvalBoard();
+    ~Rhd2000EvalBoard();
 
     int open(const char* libname);
     bool uploadFpgaBitfile(string filename);
@@ -84,8 +84,8 @@ public:
         PortD
     };
 
-    void uploadCommandList(const vector<int> &commandList, AuxCmdSlot auxCommandSlot, int bank);
-    void printCommandList(const vector<int> &commandList) const;
+    void uploadCommandList(const vector<int>& commandList, AuxCmdSlot auxCommandSlot, int bank);
+    void printCommandList(const vector<int>& commandList) const;
     void selectAuxCommandBank(BoardPort port, AuxCmdSlot auxCommandSlot, int bank);
     void selectAuxCommandLength(AuxCmdSlot auxCommandSlot, int loopIndex, int endIndex);
 
@@ -152,8 +152,8 @@ public:
 
     void flush();
     bool readDataBlock(Rhd2000DataBlock* dataBlock);
-    bool readDataBlocks(int numBlocks, queue<Rhd2000DataBlock> &dataQueue);
-    int queueToFile(queue<Rhd2000DataBlock> &dataQueue, std::ofstream& saveOut);
+    bool readDataBlocks(int numBlocks, queue<Rhd2000DataBlock>& dataQueue);
+    int queueToFile(queue<Rhd2000DataBlock>& dataQueue, std::ofstream& saveOut);
 
 private:
     okCFrontPanel* dev;
diff --git a/Source/Processors/DataThreads/rhythm-api/rhd2000registers.cpp b/Source/Processors/DataThreads/rhythm-api/rhd2000registers.cpp
index ee811708b457a0afe4b47d452caa21e01198ce9c..3fe9e2aa6ad861140b86296c2ed4b5a3b139500d 100755
--- a/Source/Processors/DataThreads/rhythm-api/rhd2000registers.cpp
+++ b/Source/Processors/DataThreads/rhythm-api/rhd2000registers.cpp
@@ -783,7 +783,7 @@ int Rhd2000Registers::createRhd2000Command(Rhd2000CommandType commandType, int a
 // Create a list of 60 commands to program most RAM registers on a RHD2000 chip, read those values
 // back to confirm programming, read ROM registers, and (if calibrate == true) run ADC calibration.
 // Returns the length of the command list.
-int Rhd2000Registers::createCommandListRegisterConfig(vector<int> &commandList, bool calibrate)
+int Rhd2000Registers::createCommandListRegisterConfig(vector<int>& commandList, bool calibrate)
 {
     commandList.clear();    // if command list already exists, erase it and start a new one
 
@@ -888,7 +888,7 @@ int Rhd2000Registers::createCommandListRegisterConfig(vector<int> &commandList,
 // different RAM banks, and the appropriate command list selected at the right time.
 //
 // Returns the length of the command list.
-int Rhd2000Registers::createCommandListTempSensor(vector<int> &commandList)
+int Rhd2000Registers::createCommandListTempSensor(vector<int>& commandList)
 {
     int i;
 
@@ -954,7 +954,7 @@ int Rhd2000Registers::createCommandListTempSensor(vector<int> &commandList)
 // amplitude (in DAC steps, 0-128) using the on-chip impedance testing voltage DAC.  If frequency is set to zero,
 // a DC baseline waveform is created.
 // Returns the length of the command list.
-int Rhd2000Registers::createCommandListZcheckDac(vector<int> &commandList, double frequency, double amplitude)
+int Rhd2000Registers::createCommandListZcheckDac(vector<int>& commandList, double frequency, double amplitude)
 {
     int i, period, value;
     double t;
diff --git a/Source/Processors/DataThreads/rhythm-api/rhd2000registers.h b/Source/Processors/DataThreads/rhythm-api/rhd2000registers.h
index 71a552a1c9407bbcdf69e8fc97f7b372ad6994e3..74ee25e89bc8b6f698150193fe1c5672200db81d 100755
--- a/Source/Processors/DataThreads/rhythm-api/rhd2000registers.h
+++ b/Source/Processors/DataThreads/rhythm-api/rhd2000registers.h
@@ -75,9 +75,9 @@ public:
     double setUpperBandwidth(double upperBandwidth);
     double setLowerBandwidth(double lowerBandwidth);
 
-    int createCommandListRegisterConfig(vector<int> &commandList, bool calibrate);
-    int createCommandListTempSensor(vector<int> &commandList);
-    int createCommandListZcheckDac(vector<int> &commandList, double frequency, double amplitude);
+    int createCommandListRegisterConfig(vector<int>& commandList, bool calibrate);
+    int createCommandListTempSensor(vector<int>& commandList);
+    int createCommandListZcheckDac(vector<int>& commandList, double frequency, double amplitude);
 
     enum Rhd2000CommandType
     {
diff --git a/Source/Processors/Editors/AudioEditor.cpp b/Source/Processors/Editors/AudioEditor.cpp
index 4f6a2dd35cb99980ffa9fc15fc950fabbba2899c..184c870c92cce3d5818fe86212fa959f8b40e450 100755
--- a/Source/Processors/Editors/AudioEditor.cpp
+++ b/Source/Processors/Editors/AudioEditor.cpp
@@ -95,7 +95,7 @@ AudioEditor::AudioEditor(AudioNode* owner)
     audioWindowButton = new AudioWindowButton();
     audioWindowButton->addListener(this);
     audioWindowButton->setToggleState(false, dontSendNotification);
-    
+
     //AccessClass* audioNode = (AccessClass*) getAudioProcessor();
     //
     addAndMakeVisible(audioWindowButton);
@@ -112,10 +112,10 @@ AudioEditor::AudioEditor(AudioNode* owner)
     noiseGateSlider->setRange(0,100,1);
     noiseGateSlider->addListener(this);
     noiseGateSlider->setTextBoxStyle(Slider::NoTextBox,
-                                  false, 0, 0);
+                                     false, 0, 0);
     addAndMakeVisible(noiseGateSlider);
 
-    
+
     //acw = new AudioConfigurationWindow(getAudioComponent()->deviceManager, (Button*) audioWindowButton);
 
 }
@@ -143,10 +143,10 @@ bool AudioEditor::keyPressed(const KeyPress& key)
 
 void AudioEditor::updateBufferSizeText()
 {
-    
+
     String t = String(getAudioComponent()->getBufferSizeMs());
     t += " ms";
-    
+
     audioWindowButton->setText(t);
 }
 
@@ -244,9 +244,9 @@ void AudioEditor::saveStateToXml(XmlElement* xml)
     audioEditorState->setAttribute("volume",volumeSlider->getValue());
     audioEditorState->setAttribute("noiseGate",noiseGateSlider->getValue());
 
-   // String audioDeviceName = getAudioComponent()->deviceManager.getCurrentAudioDeviceType();
+    // String audioDeviceName = getAudioComponent()->deviceManager.getCurrentAudioDeviceType();
 
-   // audioEditorState->setAttribute("deviceType",audioDeviceName);
+    // audioEditorState->setAttribute("deviceType",audioDeviceName);
 
 }
 
@@ -262,8 +262,8 @@ void AudioEditor::loadStateFromXml(XmlElement* xml)
             volumeSlider->setValue(xmlNode->getDoubleAttribute("volume",0.0f),NotificationType::sendNotification);
             noiseGateSlider->setValue(xmlNode->getDoubleAttribute("noiseGate",0.0f),NotificationType::sendNotification);
 
-        //    String audioDeviceName = xmlNode->getStringAttribute("deviceType","");
-        //    getAudioComponent()->deviceManager.setCurrentAudioDeviceType(audioDeviceName, true);
+            //    String audioDeviceName = xmlNode->getStringAttribute("deviceType","");
+            //    getAudioComponent()->deviceManager.setCurrentAudioDeviceType(audioDeviceName, true);
         }
     }
 
@@ -312,7 +312,7 @@ AudioConfigurationWindow::~AudioConfigurationWindow()
 void AudioConfigurationWindow::closeButtonPressed()
 {
     controlButton->setToggleState(false, dontSendNotification);
-    
+
     //updateBufferSizeText();
     String t = String(getAudioComponent()->getBufferSizeMs());
     t += " ms";
diff --git a/Source/Processors/Editors/AudioEditor.h b/Source/Processors/Editors/AudioEditor.h
index 7b657d194ac3842e167ee07d0227508de108baa0..2cc91107d32ab8a7501b8f39454da438f80a0bde 100755
--- a/Source/Processors/Editors/AudioEditor.h
+++ b/Source/Processors/Editors/AudioEditor.h
@@ -111,7 +111,7 @@ public:
     bool keyPressed(const KeyPress& key);
 
     void resized();
-    
+
     void updateBufferSizeText();
 
     void enable();
@@ -135,7 +135,7 @@ private:
 
     Slider* volumeSlider;
     Slider* noiseGateSlider;
-    
+
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AudioEditor);
 
 };
diff --git a/Source/Processors/Editors/ChannelMappingEditor.cpp b/Source/Processors/Editors/ChannelMappingEditor.cpp
index 8afc47ddf56422dfb3a648c5e6d6070331ba1e41..c18fa487ba14d52ade34b4fd56df33aa26700eb0 100644
--- a/Source/Processors/Editors/ChannelMappingEditor.cpp
+++ b/Source/Processors/Editors/ChannelMappingEditor.cpp
@@ -30,53 +30,53 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 ChannelMappingEditor::ChannelMappingEditor(GenericProcessor* parentNode, bool useDefaultParameterEditors=true)
-	: GenericEditor(parentNode, useDefaultParameterEditors), previousChannelCount(0), isConfigured(false)
+    : GenericEditor(parentNode, useDefaultParameterEditors), previousChannelCount(0), isConfigured(false)
 
 {
-	desiredWidth = 340;
+    desiredWidth = 340;
 
     scrollDistance = 0;
 
-	selectAllButton = new ElectrodeEditorButton("Select All",Font("Small Text",14,Font::plain));
-	selectAllButton->addListener(this);
-	addAndMakeVisible(selectAllButton);
-	selectAllButton->setBounds(125,110,110,10);
-	selectAllButton->setToggleState(false, dontSendNotification);
-
-	modifyButton = new ElectrodeEditorButton("Remap",Font("Small Text",14,Font::plain));
-	modifyButton->addListener(this);
-	addAndMakeVisible(modifyButton);
-	modifyButton->setBounds(220,110,60,10);
-	modifyButton->setToggleState(false, dontSendNotification);
-	modifyButton->setClickingTogglesState(true);
-
-	resetButton = new ElectrodeEditorButton("Reset", Font("Small Text",14,Font::plain));
-	resetButton->addListener(this);
-	addAndMakeVisible(resetButton);
-	resetButton->setBounds(285,110,60,10);
-	resetButton->setToggleState(true, dontSendNotification);
-	resetButton->setClickingTogglesState(false);
-	resetButton->setEnabled(false);
-
-	//    channelSelector->setRadioStatus(true);
-
-	for (int i = 0 ; i < NUM_REFERENCES; i++)
-	{
-		ElectrodeButton *button = new ElectrodeButton(i+1);
-		referenceButtons.add(button);
+    selectAllButton = new ElectrodeEditorButton("Select All",Font("Small Text",14,Font::plain));
+    selectAllButton->addListener(this);
+    addAndMakeVisible(selectAllButton);
+    selectAllButton->setBounds(125,110,110,10);
+    selectAllButton->setToggleState(false, dontSendNotification);
+
+    modifyButton = new ElectrodeEditorButton("Remap",Font("Small Text",14,Font::plain));
+    modifyButton->addListener(this);
+    addAndMakeVisible(modifyButton);
+    modifyButton->setBounds(220,110,60,10);
+    modifyButton->setToggleState(false, dontSendNotification);
+    modifyButton->setClickingTogglesState(true);
+
+    resetButton = new ElectrodeEditorButton("Reset", Font("Small Text",14,Font::plain));
+    resetButton->addListener(this);
+    addAndMakeVisible(resetButton);
+    resetButton->setBounds(285,110,60,10);
+    resetButton->setToggleState(true, dontSendNotification);
+    resetButton->setClickingTogglesState(false);
+    resetButton->setEnabled(false);
+
+    //    channelSelector->setRadioStatus(true);
+
+    for (int i = 0 ; i < NUM_REFERENCES; i++)
+    {
+        ElectrodeButton* button = new ElectrodeButton(i+1);
+        referenceButtons.add(button);
 
-		button->setBounds(10+i*30,110,20,15);
-		button->setToggleState(false, dontSendNotification);
-		button->setRadioGroupId(900);
+        button->setBounds(10+i*30,110,20,15);
+        button->setToggleState(false, dontSendNotification);
+        button->setRadioGroupId(900);
 
-		addAndMakeVisible(button);
-		button->addListener(this);
-		button->setButtonText(String::charToString('A'+i));
+        addAndMakeVisible(button);
+        button->addListener(this);
+        button->setButtonText(String::charToString('A'+i));
 
-	}
+    }
 
-	reorderActive = false;
-	isDragging = false;
+    reorderActive = false;
+    isDragging = false;
 
 }
 
@@ -87,104 +87,105 @@ ChannelMappingEditor::~ChannelMappingEditor()
 
 void ChannelMappingEditor::updateSettings()
 {
-	if (isConfigured)
-	{	
-		if (getProcessor()->getNumInputs() > previousChannelCount)
-		{
-			createElectrodeButtons(getProcessor()->getNumInputs(),false);
-			previousChannelCount = getProcessor()->getNumInputs();
-		}
-		else if (!reorderActive)
-		{
-			checkUnusedChannels();
-		}
-
-	} else if (getProcessor()->getNumInputs() != previousChannelCount)
-	{
-		createElectrodeButtons(getProcessor()->getNumInputs());
-		previousChannelCount = getProcessor()->getNumInputs();
-	}
+    if (isConfigured)
+    {
+        if (getProcessor()->getNumInputs() > previousChannelCount)
+        {
+            createElectrodeButtons(getProcessor()->getNumInputs(),false);
+            previousChannelCount = getProcessor()->getNumInputs();
+        }
+        else if (!reorderActive)
+        {
+            checkUnusedChannels();
+        }
+
+    }
+    else if (getProcessor()->getNumInputs() != previousChannelCount)
+    {
+        createElectrodeButtons(getProcessor()->getNumInputs());
+        previousChannelCount = getProcessor()->getNumInputs();
+    }
 }
 
 void ChannelMappingEditor::createElectrodeButtons(int numNeeded, bool clearPrevious)
 {
-	int startButton;
-
-	if (clearPrevious)
-	{
-		electrodeButtons.clear();
-
-		referenceArray.clear();
-		channelArray.clear();
-		referenceChannels.clear();
-		enabledChannelArray.clear();
-		startButton=0;
-		previousClickedChan = -1;
-		previousShiftClickedChan = -1;
-		referenceButtons[0]->setToggleState(true, dontSendNotification);
-		selectedReference = 0;
-		modifyButton->setToggleState(false, dontSendNotification);
-		reorderActive = false;
-		channelSelector->activateButtons();
-
-	}
-	else
-	{
-		startButton = previousChannelCount;
-		if (startButton > numNeeded) return;
-		//row = startButton/16;
-		//column = startButton % 16;
-	}
-
-	for (int i = startButton; i < numNeeded; i++)
-	{
-		ElectrodeButton* button = new ElectrodeButton(i+1);
-		electrodeButtons.add(button);
-
-		button->setRadioGroupId(0);
-		
+    int startButton;
+
+    if (clearPrevious)
+    {
+        electrodeButtons.clear();
+
+        referenceArray.clear();
+        channelArray.clear();
+        referenceChannels.clear();
+        enabledChannelArray.clear();
+        startButton=0;
+        previousClickedChan = -1;
+        previousShiftClickedChan = -1;
+        referenceButtons[0]->setToggleState(true, dontSendNotification);
+        selectedReference = 0;
+        modifyButton->setToggleState(false, dontSendNotification);
+        reorderActive = false;
+        channelSelector->activateButtons();
+
+    }
+    else
+    {
+        startButton = previousChannelCount;
+        if (startButton > numNeeded) return;
+        //row = startButton/16;
+        //column = startButton % 16;
+    }
+
+    for (int i = startButton; i < numNeeded; i++)
+    {
+        ElectrodeButton* button = new ElectrodeButton(i+1);
+        electrodeButtons.add(button);
+
+        button->setRadioGroupId(0);
+
         // if (!getCollapsedState())
         //     addAndMakeVisible(button);
         // else
         addChildComponent(button); // determine visibility in refreshButtonLocations()
 
-		button->addListener(this);
-		if (reorderActive)
-		{
-			button->setToggleState(true,dontSendNotification);
-			electrodeButtons[i]->setClickingTogglesState(false);
-			electrodeButtons[i]->addMouseListener(this,false);
-		}
-		else
-		{
-			button->setToggleState(false,dontSendNotification);
-			electrodeButtons[i]->setClickingTogglesState(true);
-		}
-		
-		referenceArray.add(-1);
-
-		getProcessor()->setCurrentChannel(i);
-		getProcessor()->setParameter(0,i); // set channel mapping to standard channel
-		getProcessor()->setParameter(1,-1); // set reference to none
-		getProcessor()->setParameter(3,1); //enable channel
-
-		channelArray.add(i+1);
-		enabledChannelArray.add(true);
-
-	}
-
-	if (clearPrevious)
-	{
-		getProcessor()->setCurrentChannel(-1);
-		for (int i = 0; i < NUM_REFERENCES; i++)
-		{
-
-			getProcessor()->setParameter(2,i); //Clear reference
-			referenceChannels.add(-1);
-			referenceButtons[i]->setEnabled(true);
-		}
-	}
-	channelSelector->setRadioStatus(true);
+        button->addListener(this);
+        if (reorderActive)
+        {
+            button->setToggleState(true,dontSendNotification);
+            electrodeButtons[i]->setClickingTogglesState(false);
+            electrodeButtons[i]->addMouseListener(this,false);
+        }
+        else
+        {
+            button->setToggleState(false,dontSendNotification);
+            electrodeButtons[i]->setClickingTogglesState(true);
+        }
+
+        referenceArray.add(-1);
+
+        getProcessor()->setCurrentChannel(i);
+        getProcessor()->setParameter(0,i); // set channel mapping to standard channel
+        getProcessor()->setParameter(1,-1); // set reference to none
+        getProcessor()->setParameter(3,1); //enable channel
+
+        channelArray.add(i+1);
+        enabledChannelArray.add(true);
+
+    }
+
+    if (clearPrevious)
+    {
+        getProcessor()->setCurrentChannel(-1);
+        for (int i = 0; i < NUM_REFERENCES; i++)
+        {
+
+            getProcessor()->setParameter(2,i); //Clear reference
+            referenceChannels.add(-1);
+            referenceButtons[i]->setEnabled(true);
+        }
+    }
+    channelSelector->setRadioStatus(true);
 
     refreshButtonLocations();
 }
@@ -224,561 +225,561 @@ void ChannelMappingEditor::collapsedStateChanged()
 void ChannelMappingEditor::buttonEvent(Button* button)
 {
 
-	if (button == selectAllButton)
-	{
-		for (int i = 0; i < electrodeButtons.size(); i++)
-		{
-			electrodeButtons[i]->setToggleState(true,dontSendNotification);
-			setChannelReference(electrodeButtons[i]);
-		}
-		previousClickedChan = -1;
-		setConfigured(true);		
-	}
-	else if (button == resetButton)
-	{
-		createElectrodeButtons(getProcessor()->getNumInputs());
-		previousChannelCount = getProcessor()->getNumInputs();
-		setConfigured(false);
-		getEditorViewport()->makeEditorVisible(this, false, true);
-	}
-	else if (button == modifyButton)
-	{
-		if (reorderActive)
-		{
-			channelSelector->activateButtons();
-			reorderActive = false;
-			selectedReference = 0;
-			for (int i = 0; i < referenceButtons.size(); i++)
-			{
-				referenceButtons[i]->setEnabled(true);
-			}
-			referenceButtons[0]->setToggleState(true, dontSendNotification);
-			Array<int> a;
-
-			if (referenceChannels[selectedReference] >= 0 )
-			{
-				a.add(referenceChannels[selectedReference]);
-			}
-			channelSelector->setActiveChannels(a);
-
-			for (int i = 0; i < electrodeButtons.size(); i++)
-			{
-				electrodeButtons[i]->setClickingTogglesState(true);
-				electrodeButtons[i]->removeMouseListener(this);
-				if (referenceArray[electrodeButtons[i]->getChannelNum()-1] == selectedReference)
-				{
-					electrodeButtons[i]->setToggleState(true, dontSendNotification);
-				}
-				else
-				{
-					electrodeButtons[i]->setToggleState(false, dontSendNotification);
-				}
-				if ((enabledChannelArray[electrodeButtons[i]->getChannelNum()-1]) && (electrodeButtons[i]->getChannelNum() <= getProcessor()->getNumInputs()))
-				{
-					electrodeButtons[i]->setEnabled(true);
-				}
-				else
-				{
-					electrodeButtons[i]->setEnabled(false);
-				}
-			}
-			selectAllButton->setEnabled(true);
-		}
-		else
-		{
-			reorderActive = true;
-			channelSelector->inactivateButtons();
-
-			for (int i=0; i < referenceButtons.size(); i++)
-			{
-				referenceButtons[i]->setEnabled(false);
-				referenceButtons[i]->setToggleState(false, dontSendNotification);
-			}
-
-			for (int i = 0; i < electrodeButtons.size(); i++)
-			{
-				electrodeButtons[i]->setClickingTogglesState(false);
-				electrodeButtons[i]->setEnabled(true);
-				if (enabledChannelArray[electrodeButtons[i]->getChannelNum()-1])
-				{
-					electrodeButtons[i]->setToggleState(true, dontSendNotification);
-				}
-				else
-				{
-					electrodeButtons[i]->setToggleState(false, dontSendNotification);
-				}
-				electrodeButtons[i]->addMouseListener(this,false);
-
-			}
-			selectAllButton->setEnabled(false);
-		}
-	}
-	else if (referenceButtons.contains((ElectrodeButton*)button))
-	{
-		selectedReference = ((ElectrodeButton*)button)->getChannelNum()-1;
-
-		Array<int> a;
-
-		if ((referenceChannels[selectedReference] >= 0 ) 
-			&& (referenceChannels[selectedReference] < channelSelector->getNumChannels() ))
-		{
-			a.add(referenceChannels[selectedReference]);
-		}
-		channelSelector->setActiveChannels(a);
-
-		for (int i = 0; i < electrodeButtons.size(); i++)
-		{
-			if (referenceArray[electrodeButtons[i]->getChannelNum()-1] == selectedReference)
-			{
-				electrodeButtons[i]->setToggleState(true, dontSendNotification);
-			}
-			else
-			{
-				electrodeButtons[i]->setToggleState(false, dontSendNotification);
-			}
-		}
-		previousClickedChan = -1;
-
-	}
-	else if (electrodeButtons.contains((ElectrodeButton*)button))
-	{
-		if (!reorderActive)
-		{
-			setConfigured(true);
-			int clickedChan = electrodeButtons.indexOf((ElectrodeButton*)button);
-
-			if (ModifierKeys::getCurrentModifiers().isShiftDown() && (previousClickedChan >= 0))
-			{
-				int toChanA,toChanD,fromChanA,fromChanD;
-
-				if (previousShiftClickedChan < 0)
-				{
-					previousShiftClickedChan = clickedChan;
-					if (clickedChan > previousClickedChan)
-					{
-						toChanA = clickedChan;
-						fromChanA = previousClickedChan;
-					}
-					else
-					{
-						toChanA = previousClickedChan;
-						fromChanA = clickedChan;
-					}
-					for (int i = fromChanA; i <= toChanA; i++)
-					{
-						electrodeButtons[i]->setToggleState(previousClickedState, dontSendNotification);
-						setChannelReference(electrodeButtons[i]);
-					}
-				}
-				else 
-				{
-					if ((clickedChan > previousClickedChan) && (clickedChan > previousShiftClickedChan))
-					{
-						fromChanA = previousShiftClickedChan+1;
-						toChanA = clickedChan;
-						if (previousShiftClickedChan < previousClickedChan)
-						{
-							fromChanD = previousShiftClickedChan;
-							toChanD = previousClickedChan-1;
-						}
-						else
-						{
-							fromChanD = -1;
-						}
-					}
-					else if ((clickedChan > previousClickedChan) && (clickedChan < previousShiftClickedChan))
-					{
-						fromChanA = -1;
-						fromChanD = clickedChan+1;
-						toChanD = previousShiftClickedChan;
-						button->setToggleState(previousClickedState, dontSendNotification); // Do not toggle this button;
-					}
-					else if ((clickedChan < previousClickedChan) && (clickedChan < previousShiftClickedChan))
-					{
-						fromChanA = clickedChan;
-						toChanA = previousShiftClickedChan-1;
-						if (previousShiftClickedChan > previousClickedChan)
-						{
-							fromChanD = previousClickedChan+1;
-							toChanD = previousShiftClickedChan;
-						}
-						else
-						{
-							fromChanD = -1;
-						}
-					}
-					else if ((clickedChan < previousClickedChan) && (clickedChan > previousShiftClickedChan))
-					{
-						fromChanA = -1;
-						fromChanD = previousShiftClickedChan;
-						toChanD = clickedChan - 1;
-						button->setToggleState(previousClickedState, dontSendNotification); // Do not toggle this button;
-					}
-					else if (clickedChan == previousShiftClickedChan)
-					{
-						fromChanA = -1;
-						fromChanD = -1;
-						button->setToggleState(previousClickedState, dontSendNotification); // Do not toggle this button;
-					}
-					else
-					{
-						fromChanA = -1;
-						button->setToggleState(previousClickedState, dontSendNotification); // Do not toggle this button;
-						if (previousShiftClickedChan < previousClickedChan)
-						{
-							fromChanD = previousShiftClickedChan;
-							toChanD = previousClickedChan - 1;
-						}
-						else if (previousShiftClickedChan > previousClickedChan)
-						{
-							fromChanD = previousClickedChan + 1;
-							toChanD = previousShiftClickedChan;
-						}
-						else
-						{
-							fromChanD = -1;
-						}
-					}
-
-					if (fromChanA >= 0)
-					{
-						for (int i = fromChanA; i <= toChanA; i++)
-						{
-							electrodeButtons[i]->setToggleState(previousClickedState, dontSendNotification);
-							setChannelReference(electrodeButtons[i]);
-						}
-					}
-					if (fromChanD >= 0)
-					{
-						for (int i = fromChanD; i <= toChanD; i++)
-						{
-							electrodeButtons[i]->setToggleState(!previousClickedState, dontSendNotification);
-							setChannelReference(electrodeButtons[i]);
-						}
-					}
-				}
-
-				previousShiftClickedChan = clickedChan;
-			}
-			else
-			{
-				previousClickedChan = clickedChan;
-				previousShiftClickedChan = -1;
-				setChannelReference((ElectrodeButton*)button);
-				previousClickedState = button->getToggleState();
-			}
-
-
-		}
-	}
+    if (button == selectAllButton)
+    {
+        for (int i = 0; i < electrodeButtons.size(); i++)
+        {
+            electrodeButtons[i]->setToggleState(true,dontSendNotification);
+            setChannelReference(electrodeButtons[i]);
+        }
+        previousClickedChan = -1;
+        setConfigured(true);
+    }
+    else if (button == resetButton)
+    {
+        createElectrodeButtons(getProcessor()->getNumInputs());
+        previousChannelCount = getProcessor()->getNumInputs();
+        setConfigured(false);
+        getEditorViewport()->makeEditorVisible(this, false, true);
+    }
+    else if (button == modifyButton)
+    {
+        if (reorderActive)
+        {
+            channelSelector->activateButtons();
+            reorderActive = false;
+            selectedReference = 0;
+            for (int i = 0; i < referenceButtons.size(); i++)
+            {
+                referenceButtons[i]->setEnabled(true);
+            }
+            referenceButtons[0]->setToggleState(true, dontSendNotification);
+            Array<int> a;
+
+            if (referenceChannels[selectedReference] >= 0)
+            {
+                a.add(referenceChannels[selectedReference]);
+            }
+            channelSelector->setActiveChannels(a);
+
+            for (int i = 0; i < electrodeButtons.size(); i++)
+            {
+                electrodeButtons[i]->setClickingTogglesState(true);
+                electrodeButtons[i]->removeMouseListener(this);
+                if (referenceArray[electrodeButtons[i]->getChannelNum()-1] == selectedReference)
+                {
+                    electrodeButtons[i]->setToggleState(true, dontSendNotification);
+                }
+                else
+                {
+                    electrodeButtons[i]->setToggleState(false, dontSendNotification);
+                }
+                if ((enabledChannelArray[electrodeButtons[i]->getChannelNum()-1]) && (electrodeButtons[i]->getChannelNum() <= getProcessor()->getNumInputs()))
+                {
+                    electrodeButtons[i]->setEnabled(true);
+                }
+                else
+                {
+                    electrodeButtons[i]->setEnabled(false);
+                }
+            }
+            selectAllButton->setEnabled(true);
+        }
+        else
+        {
+            reorderActive = true;
+            channelSelector->inactivateButtons();
+
+            for (int i=0; i < referenceButtons.size(); i++)
+            {
+                referenceButtons[i]->setEnabled(false);
+                referenceButtons[i]->setToggleState(false, dontSendNotification);
+            }
+
+            for (int i = 0; i < electrodeButtons.size(); i++)
+            {
+                electrodeButtons[i]->setClickingTogglesState(false);
+                electrodeButtons[i]->setEnabled(true);
+                if (enabledChannelArray[electrodeButtons[i]->getChannelNum()-1])
+                {
+                    electrodeButtons[i]->setToggleState(true, dontSendNotification);
+                }
+                else
+                {
+                    electrodeButtons[i]->setToggleState(false, dontSendNotification);
+                }
+                electrodeButtons[i]->addMouseListener(this,false);
+
+            }
+            selectAllButton->setEnabled(false);
+        }
+    }
+    else if (referenceButtons.contains((ElectrodeButton*)button))
+    {
+        selectedReference = ((ElectrodeButton*)button)->getChannelNum()-1;
+
+        Array<int> a;
+
+        if ((referenceChannels[selectedReference] >= 0)
+            && (referenceChannels[selectedReference] < channelSelector->getNumChannels()))
+        {
+            a.add(referenceChannels[selectedReference]);
+        }
+        channelSelector->setActiveChannels(a);
+
+        for (int i = 0; i < electrodeButtons.size(); i++)
+        {
+            if (referenceArray[electrodeButtons[i]->getChannelNum()-1] == selectedReference)
+            {
+                electrodeButtons[i]->setToggleState(true, dontSendNotification);
+            }
+            else
+            {
+                electrodeButtons[i]->setToggleState(false, dontSendNotification);
+            }
+        }
+        previousClickedChan = -1;
+
+    }
+    else if (electrodeButtons.contains((ElectrodeButton*)button))
+    {
+        if (!reorderActive)
+        {
+            setConfigured(true);
+            int clickedChan = electrodeButtons.indexOf((ElectrodeButton*)button);
+
+            if (ModifierKeys::getCurrentModifiers().isShiftDown() && (previousClickedChan >= 0))
+            {
+                int toChanA,toChanD,fromChanA,fromChanD;
+
+                if (previousShiftClickedChan < 0)
+                {
+                    previousShiftClickedChan = clickedChan;
+                    if (clickedChan > previousClickedChan)
+                    {
+                        toChanA = clickedChan;
+                        fromChanA = previousClickedChan;
+                    }
+                    else
+                    {
+                        toChanA = previousClickedChan;
+                        fromChanA = clickedChan;
+                    }
+                    for (int i = fromChanA; i <= toChanA; i++)
+                    {
+                        electrodeButtons[i]->setToggleState(previousClickedState, dontSendNotification);
+                        setChannelReference(electrodeButtons[i]);
+                    }
+                }
+                else
+                {
+                    if ((clickedChan > previousClickedChan) && (clickedChan > previousShiftClickedChan))
+                    {
+                        fromChanA = previousShiftClickedChan+1;
+                        toChanA = clickedChan;
+                        if (previousShiftClickedChan < previousClickedChan)
+                        {
+                            fromChanD = previousShiftClickedChan;
+                            toChanD = previousClickedChan-1;
+                        }
+                        else
+                        {
+                            fromChanD = -1;
+                        }
+                    }
+                    else if ((clickedChan > previousClickedChan) && (clickedChan < previousShiftClickedChan))
+                    {
+                        fromChanA = -1;
+                        fromChanD = clickedChan+1;
+                        toChanD = previousShiftClickedChan;
+                        button->setToggleState(previousClickedState, dontSendNotification); // Do not toggle this button;
+                    }
+                    else if ((clickedChan < previousClickedChan) && (clickedChan < previousShiftClickedChan))
+                    {
+                        fromChanA = clickedChan;
+                        toChanA = previousShiftClickedChan-1;
+                        if (previousShiftClickedChan > previousClickedChan)
+                        {
+                            fromChanD = previousClickedChan+1;
+                            toChanD = previousShiftClickedChan;
+                        }
+                        else
+                        {
+                            fromChanD = -1;
+                        }
+                    }
+                    else if ((clickedChan < previousClickedChan) && (clickedChan > previousShiftClickedChan))
+                    {
+                        fromChanA = -1;
+                        fromChanD = previousShiftClickedChan;
+                        toChanD = clickedChan - 1;
+                        button->setToggleState(previousClickedState, dontSendNotification); // Do not toggle this button;
+                    }
+                    else if (clickedChan == previousShiftClickedChan)
+                    {
+                        fromChanA = -1;
+                        fromChanD = -1;
+                        button->setToggleState(previousClickedState, dontSendNotification); // Do not toggle this button;
+                    }
+                    else
+                    {
+                        fromChanA = -1;
+                        button->setToggleState(previousClickedState, dontSendNotification); // Do not toggle this button;
+                        if (previousShiftClickedChan < previousClickedChan)
+                        {
+                            fromChanD = previousShiftClickedChan;
+                            toChanD = previousClickedChan - 1;
+                        }
+                        else if (previousShiftClickedChan > previousClickedChan)
+                        {
+                            fromChanD = previousClickedChan + 1;
+                            toChanD = previousShiftClickedChan;
+                        }
+                        else
+                        {
+                            fromChanD = -1;
+                        }
+                    }
+
+                    if (fromChanA >= 0)
+                    {
+                        for (int i = fromChanA; i <= toChanA; i++)
+                        {
+                            electrodeButtons[i]->setToggleState(previousClickedState, dontSendNotification);
+                            setChannelReference(electrodeButtons[i]);
+                        }
+                    }
+                    if (fromChanD >= 0)
+                    {
+                        for (int i = fromChanD; i <= toChanD; i++)
+                        {
+                            electrodeButtons[i]->setToggleState(!previousClickedState, dontSendNotification);
+                            setChannelReference(electrodeButtons[i]);
+                        }
+                    }
+                }
+
+                previousShiftClickedChan = clickedChan;
+            }
+            else
+            {
+                previousClickedChan = clickedChan;
+                previousShiftClickedChan = -1;
+                setChannelReference((ElectrodeButton*)button);
+                previousClickedState = button->getToggleState();
+            }
+
+
+        }
+    }
 }
 
-void ChannelMappingEditor::setChannelReference(ElectrodeButton *button)
+void ChannelMappingEditor::setChannelReference(ElectrodeButton* button)
 {
-	int chan = button->getChannelNum()-1;
-	getProcessor()->setCurrentChannel(chan);
-
-	if (button->getToggleState())
-	{
-		referenceArray.set(chan,selectedReference);
-		getProcessor()->setParameter(1,selectedReference);				
-	}
-	else
-	{
-		referenceArray.set(chan,-1);
-		getProcessor()->setParameter(1,-1);				
-	}
+    int chan = button->getChannelNum()-1;
+    getProcessor()->setCurrentChannel(chan);
+
+    if (button->getToggleState())
+    {
+        referenceArray.set(chan,selectedReference);
+        getProcessor()->setParameter(1,selectedReference);
+    }
+    else
+    {
+        referenceArray.set(chan,-1);
+        getProcessor()->setParameter(1,-1);
+    }
 
 }
 
 void ChannelMappingEditor::channelChanged(int chan)
 {
-	if (!reorderActive)
-	{
-		setConfigured(true);
-		getProcessor()->setCurrentChannel(chan-1);
-		getProcessor()->setParameter(2,selectedReference);
-		referenceChannels.set(selectedReference,chan-1);
-	}
+    if (!reorderActive)
+    {
+        setConfigured(true);
+        getProcessor()->setCurrentChannel(chan-1);
+        getProcessor()->setParameter(2,selectedReference);
+        referenceChannels.set(selectedReference,chan-1);
+    }
 }
 
 void ChannelMappingEditor::saveCustomParameters(XmlElement* xml)
 {
-	xml->setAttribute("Type", "ChannelMappingEditor");
-
-	//Made a bit generic in case future expansions need more settings
-	XmlElement* settingsXml = xml->createNewChildElement("SETTING");
-	settingsXml->setAttribute("Type","visibleChannels");
-	settingsXml->setAttribute("Value",previousChannelCount);
-	for (int i = 0; i < channelArray.size(); i++)
-	{
-		XmlElement* channelXml = xml->createNewChildElement("CHANNEL");
-		channelXml->setAttribute("Number", i);
-		channelXml->setAttribute("Mapping", channelArray[i]);
-		channelXml->setAttribute("Reference", referenceArray[channelArray[i]-1]);
-		channelXml->setAttribute("Enabled",enabledChannelArray[channelArray[i]-1]);
-	}
-	for (int i = 0; i< referenceChannels.size(); i++)
-	{
-		XmlElement* referenceXml = xml->createNewChildElement("REFERENCE");
-		referenceXml->setAttribute("Number", i);
-		referenceXml->setAttribute("Channel",referenceChannels[i]);
-	}
+    xml->setAttribute("Type", "ChannelMappingEditor");
+
+    //Made a bit generic in case future expansions need more settings
+    XmlElement* settingsXml = xml->createNewChildElement("SETTING");
+    settingsXml->setAttribute("Type","visibleChannels");
+    settingsXml->setAttribute("Value",previousChannelCount);
+    for (int i = 0; i < channelArray.size(); i++)
+    {
+        XmlElement* channelXml = xml->createNewChildElement("CHANNEL");
+        channelXml->setAttribute("Number", i);
+        channelXml->setAttribute("Mapping", channelArray[i]);
+        channelXml->setAttribute("Reference", referenceArray[channelArray[i]-1]);
+        channelXml->setAttribute("Enabled",enabledChannelArray[channelArray[i]-1]);
+    }
+    for (int i = 0; i< referenceChannels.size(); i++)
+    {
+        XmlElement* referenceXml = xml->createNewChildElement("REFERENCE");
+        referenceXml->setAttribute("Number", i);
+        referenceXml->setAttribute("Channel",referenceChannels[i]);
+    }
 
 }
 
 void ChannelMappingEditor::loadCustomParameters(XmlElement* xml)
 {
-	setConfigured(true);
-	forEachXmlChildElementWithTagName(*xml,	settingXml, "SETTING")
-	{
-		if (settingXml->getStringAttribute("Type").equalsIgnoreCase("visibleChannels"))
-		{
-			int nChans = settingXml->getIntAttribute("Value");
-			if (nChans > getProcessor()->getNumInputs())
-			{
-				createElectrodeButtons(nChans,false);
-			}
-		}
-	}
-	forEachXmlChildElementWithTagName(*xml, channelXml, "CHANNEL")
-	{
-		int i = channelXml->getIntAttribute("Number");
+    setConfigured(true);
+    forEachXmlChildElementWithTagName(*xml,	settingXml, "SETTING")
+    {
+        if (settingXml->getStringAttribute("Type").equalsIgnoreCase("visibleChannels"))
+        {
+            int nChans = settingXml->getIntAttribute("Value");
+            if (nChans > getProcessor()->getNumInputs())
+            {
+                createElectrodeButtons(nChans,false);
+            }
+        }
+    }
+    forEachXmlChildElementWithTagName(*xml, channelXml, "CHANNEL")
+    {
+        int i = channelXml->getIntAttribute("Number");
 
-		if (i < channelArray.size())
-		{
+        if (i < channelArray.size())
+        {
 
-			int mapping = channelXml->getIntAttribute("Mapping");
-			int reference = channelXml->getIntAttribute("Reference");
-			bool enabled = channelXml->getBoolAttribute("Enabled");
+            int mapping = channelXml->getIntAttribute("Mapping");
+            int reference = channelXml->getIntAttribute("Reference");
+            bool enabled = channelXml->getBoolAttribute("Enabled");
 
-			channelArray.set(i, mapping);
-			referenceArray.set(mapping-1, reference);
-			enabledChannelArray.set(mapping-1,enabled);
+            channelArray.set(i, mapping);
+            referenceArray.set(mapping-1, reference);
+            enabledChannelArray.set(mapping-1,enabled);
 
-			electrodeButtons[i]->setChannelNum(mapping);
-			electrodeButtons[i]->setEnabled(enabled);
-			electrodeButtons[i]->repaint();
+            electrodeButtons[i]->setChannelNum(mapping);
+            electrodeButtons[i]->setEnabled(enabled);
+            electrodeButtons[i]->repaint();
 
 
-			getProcessor()->setCurrentChannel(i);
+            getProcessor()->setCurrentChannel(i);
 
-			getProcessor()->setParameter(0, mapping-1); // set mapping
+            getProcessor()->setParameter(0, mapping-1); // set mapping
 
-			getProcessor()->setCurrentChannel(mapping-1);
+            getProcessor()->setCurrentChannel(mapping-1);
 
-			getProcessor()->setParameter(1, reference); // set reference			
+            getProcessor()->setParameter(1, reference); // set reference
 
-			getProcessor()->setParameter(3,enabled ? 1 : 0); //set enabled
-		}
+            getProcessor()->setParameter(3,enabled ? 1 : 0); //set enabled
+        }
 
-	}
+    }
 
-	forEachXmlChildElementWithTagName(*xml, referenceXml, "REFERENCE")
-	{
-		int i = referenceXml->getIntAttribute("Number");
+    forEachXmlChildElementWithTagName(*xml, referenceXml, "REFERENCE")
+    {
+        int i = referenceXml->getIntAttribute("Number");
 
-		if ( i < referenceChannels.size() )
-		{
-			int channel = referenceXml->getIntAttribute("Channel");
+        if (i < referenceChannels.size())
+        {
+            int channel = referenceXml->getIntAttribute("Channel");
 
-			referenceChannels.set(i,channel);
+            referenceChannels.set(i,channel);
 
-			getProcessor()->setCurrentChannel(channel);
+            getProcessor()->setCurrentChannel(channel);
 
-			getProcessor()->setParameter(2,i);
-		}
-	}
+            getProcessor()->setParameter(2,i);
+        }
+    }
 
-	for (int i = 0; i < electrodeButtons.size(); i++)
-	{
-		if (referenceArray[electrodeButtons[i]->getChannelNum()-1] == selectedReference)
-		{
-			electrodeButtons[i]->setToggleState(true, dontSendNotification);
-		}
-		else
-		{
-			electrodeButtons[i]->setToggleState(false, dontSendNotification);
-		}
-	}
+    for (int i = 0; i < electrodeButtons.size(); i++)
+    {
+        if (referenceArray[electrodeButtons[i]->getChannelNum()-1] == selectedReference)
+        {
+            electrodeButtons[i]->setToggleState(true, dontSendNotification);
+        }
+        else
+        {
+            electrodeButtons[i]->setToggleState(false, dontSendNotification);
+        }
+    }
 
     refreshButtonLocations();
 
 }
 
-void ChannelMappingEditor::mouseDrag(const MouseEvent &e)
+void ChannelMappingEditor::mouseDrag(const MouseEvent& e)
 {
-	if (reorderActive)
-	{
-		if ((!isDragging) && (electrodeButtons.contains((ElectrodeButton*) e.originalComponent) ))
-		{
-			ElectrodeButton* button = (ElectrodeButton*)e.originalComponent;
-			isDragging = true;
-
-			String desc = "EditorDrag/MAP/";
-			desc += button->getChannelNum();
-
-			const String dragDescription = desc;
-
-			Image dragImage(Image::ARGB,20,15,true);
-
-			Graphics g(dragImage);
-			if (button->getToggleState())
-			{
-				g.setColour(Colours::orange);
-			}
-			else
-			{
-				g.setColour(Colours::darkgrey);
-			}
-			g.fillAll();
-			g.setColour(Colours::black);
-			g.drawText(String(button->getChannelNum()),0,0,20,15,Justification::centred,true);
-
-			dragImage.multiplyAllAlphas(0.6f);
-
-			startDragging(dragDescription,this,dragImage,false);
-			button->setVisible(false);
-			initialDraggedButton = electrodeButtons.indexOf(button);
-			lastHoverButton = initialDraggedButton;
-			draggingChannel = button->getChannelNum();
-		}
-		else if (isDragging)
-		{
-			MouseEvent ev = e.getEventRelativeTo(this);
-
-			int col = ((ev.x-5) / 20);
-			if (col < 0) col = 0;
-			else if (col > 16) col = 16;
-
-			int row = ((ev.y-30) / 15);
-			if (row < 0) row = 0;
-
-			int hoverButton = row*16+col;
-
-			if (hoverButton >= electrodeButtons.size())
-			{
-				hoverButton = electrodeButtons.size() -1;
-			}
-
-			if (hoverButton != lastHoverButton)
-			{
-
-				electrodeButtons[lastHoverButton]->setVisible(true);
-				electrodeButtons[hoverButton]->setVisible(false);
-
-				if (lastHoverButton > hoverButton)
-				{
-					for (int i = lastHoverButton; i > hoverButton; i--)
-					{
-						electrodeButtons[i]->setChannelNum(electrodeButtons[i-1]->getChannelNum());
-						if (enabledChannelArray[electrodeButtons[i]->getChannelNum()-1]) //Could be more compact, but definitely less legible
-						{
-							electrodeButtons[i]->setToggleState(true, dontSendNotification);
-						}
-						else
-						{
-							electrodeButtons[i]->setToggleState(false, dontSendNotification);
-						}
-					}
-				}
-				else
-				{
-					for (int i = lastHoverButton; i < hoverButton; i++)
-					{
-						electrodeButtons[i]->setChannelNum(electrodeButtons[i+1]->getChannelNum());
-						if (enabledChannelArray[electrodeButtons[i]->getChannelNum()-1])
-						{
-							electrodeButtons[i]->setToggleState(true, dontSendNotification);
-						}
-						else
-						{
-							electrodeButtons[i]->setToggleState(false, dontSendNotification);
-						}
-					}
-				}
-				electrodeButtons[hoverButton]->setChannelNum(draggingChannel);
-				electrodeButtons[hoverButton]->setToggleState(enabledChannelArray[draggingChannel-1], dontSendNotification);
-
-				lastHoverButton = hoverButton;
-				repaint();
-			}
-
-		}
-
-	}
+    if (reorderActive)
+    {
+        if ((!isDragging) && (electrodeButtons.contains((ElectrodeButton*) e.originalComponent)))
+        {
+            ElectrodeButton* button = (ElectrodeButton*)e.originalComponent;
+            isDragging = true;
+
+            String desc = "EditorDrag/MAP/";
+            desc += button->getChannelNum();
+
+            const String dragDescription = desc;
+
+            Image dragImage(Image::ARGB,20,15,true);
+
+            Graphics g(dragImage);
+            if (button->getToggleState())
+            {
+                g.setColour(Colours::orange);
+            }
+            else
+            {
+                g.setColour(Colours::darkgrey);
+            }
+            g.fillAll();
+            g.setColour(Colours::black);
+            g.drawText(String(button->getChannelNum()),0,0,20,15,Justification::centred,true);
+
+            dragImage.multiplyAllAlphas(0.6f);
+
+            startDragging(dragDescription,this,dragImage,false);
+            button->setVisible(false);
+            initialDraggedButton = electrodeButtons.indexOf(button);
+            lastHoverButton = initialDraggedButton;
+            draggingChannel = button->getChannelNum();
+        }
+        else if (isDragging)
+        {
+            MouseEvent ev = e.getEventRelativeTo(this);
+
+            int col = ((ev.x-5) / 20);
+            if (col < 0) col = 0;
+            else if (col > 16) col = 16;
+
+            int row = ((ev.y-30) / 15);
+            if (row < 0) row = 0;
+
+            int hoverButton = row*16+col;
+
+            if (hoverButton >= electrodeButtons.size())
+            {
+                hoverButton = electrodeButtons.size() -1;
+            }
+
+            if (hoverButton != lastHoverButton)
+            {
+
+                electrodeButtons[lastHoverButton]->setVisible(true);
+                electrodeButtons[hoverButton]->setVisible(false);
+
+                if (lastHoverButton > hoverButton)
+                {
+                    for (int i = lastHoverButton; i > hoverButton; i--)
+                    {
+                        electrodeButtons[i]->setChannelNum(electrodeButtons[i-1]->getChannelNum());
+                        if (enabledChannelArray[electrodeButtons[i]->getChannelNum()-1]) //Could be more compact, but definitely less legible
+                        {
+                            electrodeButtons[i]->setToggleState(true, dontSendNotification);
+                        }
+                        else
+                        {
+                            electrodeButtons[i]->setToggleState(false, dontSendNotification);
+                        }
+                    }
+                }
+                else
+                {
+                    for (int i = lastHoverButton; i < hoverButton; i++)
+                    {
+                        electrodeButtons[i]->setChannelNum(electrodeButtons[i+1]->getChannelNum());
+                        if (enabledChannelArray[electrodeButtons[i]->getChannelNum()-1])
+                        {
+                            electrodeButtons[i]->setToggleState(true, dontSendNotification);
+                        }
+                        else
+                        {
+                            electrodeButtons[i]->setToggleState(false, dontSendNotification);
+                        }
+                    }
+                }
+                electrodeButtons[hoverButton]->setChannelNum(draggingChannel);
+                electrodeButtons[hoverButton]->setToggleState(enabledChannelArray[draggingChannel-1], dontSendNotification);
+
+                lastHoverButton = hoverButton;
+                repaint();
+            }
+
+        }
+
+    }
 }
 
-void ChannelMappingEditor::mouseUp(const MouseEvent &e)
+void ChannelMappingEditor::mouseUp(const MouseEvent& e)
 {
-	if (isDragging)
-	{
-		isDragging = false;
-		electrodeButtons[lastHoverButton]->setVisible(true);
-		int from, to;
-		if (lastHoverButton == initialDraggedButton) 
-		{
-			return;
-		}
-		else if (lastHoverButton < initialDraggedButton)
-		{
-			from = lastHoverButton;
-			to = initialDraggedButton;
-		}
-		else
-		{
-			from = initialDraggedButton;
-			to = lastHoverButton;
-		}
-
-		for (int i=from; i <= to; i++)
-		{
-			setChannelPosition(i,electrodeButtons[i]->getChannelNum());
-		}
-		setConfigured(true);
-	}
+    if (isDragging)
+    {
+        isDragging = false;
+        electrodeButtons[lastHoverButton]->setVisible(true);
+        int from, to;
+        if (lastHoverButton == initialDraggedButton)
+        {
+            return;
+        }
+        else if (lastHoverButton < initialDraggedButton)
+        {
+            from = lastHoverButton;
+            to = initialDraggedButton;
+        }
+        else
+        {
+            from = initialDraggedButton;
+            to = lastHoverButton;
+        }
+
+        for (int i=from; i <= to; i++)
+        {
+            setChannelPosition(i,electrodeButtons[i]->getChannelNum());
+        }
+        setConfigured(true);
+    }
 }
 
 void ChannelMappingEditor::setChannelPosition(int position, int channel)
 {
-	getProcessor()->setCurrentChannel(position);
-	getProcessor()->setParameter(0,channel-1);
-	channelArray.set(position,channel);
+    getProcessor()->setCurrentChannel(position);
+    getProcessor()->setParameter(0,channel-1);
+    channelArray.set(position,channel);
 }
 
-void ChannelMappingEditor::mouseDoubleClick(const MouseEvent &e)
+void ChannelMappingEditor::mouseDoubleClick(const MouseEvent& e)
 {
-	if ((reorderActive) && electrodeButtons.contains((ElectrodeButton*)e.originalComponent))
-	{
-		setConfigured(true);
-		ElectrodeButton *button = (ElectrodeButton*)e.originalComponent;
-
-		if (button->getToggleState())
-		{
-			button->setToggleState(false, dontSendNotification);
-			enabledChannelArray.set(button->getChannelNum()-1,false);
-			getProcessor()->setCurrentChannel(button->getChannelNum()-1);
-			getProcessor()->setParameter(3,0);
-		}
-		else
-		{
-			button->setToggleState(true, dontSendNotification);
-			enabledChannelArray.set(button->getChannelNum()-1,true);
-			getProcessor()->setCurrentChannel(button->getChannelNum()-1);
-			getProcessor()->setParameter(3,1);
-		}
-		getEditorViewport()->makeEditorVisible(this, false, true);
-	}
+    if ((reorderActive) && electrodeButtons.contains((ElectrodeButton*)e.originalComponent))
+    {
+        setConfigured(true);
+        ElectrodeButton* button = (ElectrodeButton*)e.originalComponent;
+
+        if (button->getToggleState())
+        {
+            button->setToggleState(false, dontSendNotification);
+            enabledChannelArray.set(button->getChannelNum()-1,false);
+            getProcessor()->setCurrentChannel(button->getChannelNum()-1);
+            getProcessor()->setParameter(3,0);
+        }
+        else
+        {
+            button->setToggleState(true, dontSendNotification);
+            enabledChannelArray.set(button->getChannelNum()-1,true);
+            getProcessor()->setCurrentChannel(button->getChannelNum()-1);
+            getProcessor()->setParameter(3,1);
+        }
+        getEditorViewport()->makeEditorVisible(this, false, true);
+    }
 }
 
 void ChannelMappingEditor::mouseWheelMove(const MouseEvent& event,
-                                           const MouseWheelDetails& wheel)
+                                          const MouseWheelDetails& wheel)
 {
 
     float maxScrollDistance = ceil(float(electrodeButtons.size() - 80) / 16.0f);
 
-   // std::cout << "Got wheel move: " << wheel.deltaY << std::endl;
-   // channelSelector->shiftChannelsVertical(-wheel.deltaY);
+    // std::cout << "Got wheel move: " << wheel.deltaY << std::endl;
+    // channelSelector->shiftChannelsVertical(-wheel.deltaY);
     scrollDistance -= wheel.deltaY*2;
 
     if (scrollDistance > maxScrollDistance)
@@ -792,30 +793,30 @@ void ChannelMappingEditor::mouseWheelMove(const MouseEvent& event,
 
 void ChannelMappingEditor::checkUnusedChannels()
 {
-	for (int i = 0; i < electrodeButtons.size(); i++)
-	{
-		if (electrodeButtons[i]->getChannelNum() > getProcessor()->getNumInputs())
-		{
-			electrodeButtons[i]->setEnabled(false);
-		}
-		else
-		{
-			if (enabledChannelArray[electrodeButtons[i]->getChannelNum()-1])
-			{
-				electrodeButtons[i]->setEnabled(true);
-			}
-			else
-			{
-				electrodeButtons[i]->setEnabled(false);
-			}
-		}
-	}
+    for (int i = 0; i < electrodeButtons.size(); i++)
+    {
+        if (electrodeButtons[i]->getChannelNum() > getProcessor()->getNumInputs())
+        {
+            electrodeButtons[i]->setEnabled(false);
+        }
+        else
+        {
+            if (enabledChannelArray[electrodeButtons[i]->getChannelNum()-1])
+            {
+                electrodeButtons[i]->setEnabled(true);
+            }
+            else
+            {
+                electrodeButtons[i]->setEnabled(false);
+            }
+        }
+    }
 }
 void ChannelMappingEditor::setConfigured(bool state)
 {
-	isConfigured = state;
-	resetButton->setEnabled(state);
-	resetButton->setToggleState(!state, dontSendNotification);
-	getProcessor()->setParameter(4,state?1:0);
+    isConfigured = state;
+    resetButton->setEnabled(state);
+    resetButton->setToggleState(!state, dontSendNotification);
+    getProcessor()->setParameter(4,state?1:0);
 }
 
diff --git a/Source/Processors/Editors/ChannelMappingEditor.h b/Source/Processors/Editors/ChannelMappingEditor.h
index 74897536bb1611419144bb99648db7158db6cbf4..1def1ca825b9e6182be3bacd6c5b5b6779c64684 100644
--- a/Source/Processors/Editors/ChannelMappingEditor.h
+++ b/Source/Processors/Editors/ChannelMappingEditor.h
@@ -41,7 +41,7 @@
 */
 
 class ChannelMappingEditor : public GenericEditor,
-	public DragAndDropContainer
+    public DragAndDropContainer
 
 {
 public:
@@ -59,11 +59,11 @@ public:
 
     void channelChanged(int chan);
 
-	void mouseDrag(const MouseEvent &e);
+    void mouseDrag(const MouseEvent& e);
 
-	void mouseUp(const MouseEvent &e);
+    void mouseUp(const MouseEvent& e);
 
-	void mouseDoubleClick(const MouseEvent &e);
+    void mouseDoubleClick(const MouseEvent& e);
 
     void mouseWheelMove(const MouseEvent& event, const MouseWheelDetails& wheel);
 
@@ -71,39 +71,39 @@ public:
 
 private:
 
-	void setChannelReference(ElectrodeButton *button);
-	void setChannelPosition(int position, int channel);
-	void checkUnusedChannels();
-	void setConfigured(bool state);
+    void setChannelReference(ElectrodeButton* button);
+    void setChannelPosition(int position, int channel);
+    void checkUnusedChannels();
+    void setConfigured(bool state);
 
     void refreshButtonLocations();
 
-	OwnedArray<ElectrodeButton> electrodeButtons;
-	OwnedArray<ElectrodeButton> referenceButtons;
+    OwnedArray<ElectrodeButton> electrodeButtons;
+    OwnedArray<ElectrodeButton> referenceButtons;
     ScopedPointer<ElectrodeEditorButton> selectAllButton;
     ScopedPointer<ElectrodeEditorButton> modifyButton;
-	ScopedPointer<ElectrodeEditorButton> resetButton;
+    ScopedPointer<ElectrodeEditorButton> resetButton;
 
     Array<int> channelArray;
     Array<int> referenceArray;
-	Array<int> referenceChannels;
-	Array<bool> enabledChannelArray;
+    Array<int> referenceChannels;
+    Array<bool> enabledChannelArray;
 
     int previousChannelCount;
-	int selectedReference;
-	bool reorderActive;
-	int previousClickedChan;
-	int previousShiftClickedChan;
-	bool previousClickedState;
-
-	bool isDragging;
-	int initialDraggedButton;
-	int draggingChannel;
-	int lastHoverButton;
-	bool isConfigured;
+    int selectedReference;
+    bool reorderActive;
+    int previousClickedChan;
+    int previousShiftClickedChan;
+    bool previousClickedState;
+
+    bool isDragging;
+    int initialDraggedButton;
+    int draggingChannel;
+    int lastHoverButton;
+    bool isConfigured;
 
     float scrollDistance;
-	
+
 
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ChannelMappingEditor);
 
diff --git a/Source/Processors/Editors/ChannelSelector.cpp b/Source/Processors/Editors/ChannelSelector.cpp
index 39171fe8ce783a75dd0c42cd9f09d1d12e3af0d6..935e2450fda31ff87b81d8979fc3382ef422d2d2 100755
--- a/Source/Processors/Editors/ChannelSelector.cpp
+++ b/Source/Processors/Editors/ChannelSelector.cpp
@@ -113,7 +113,7 @@ void ChannelSelector::setNumChannels(int numChans)
 
     int difference = numChans - parameterButtons.size();
 
-   // std::cout << difference << " buttons needed." << std::endl;
+    // std::cout << difference << " buttons needed." << std::endl;
 
     if (difference > 0)
     {
@@ -590,7 +590,7 @@ void ChannelSelector::buttonClicked(Button* button)
             if (acquisitionIsActive) // use setParameter to change parameter safely
             {
                 editor->getProcessorGraph()->
-                    getAudioNode()->setChannelStatus(ch, status);
+                getAudioNode()->setChannelStatus(ch, status);
             }
             else     // change parameter directly
             {
@@ -612,7 +612,7 @@ void ChannelSelector::buttonClicked(Button* button)
             {
                 editor->getProcessorGraph()->
                 getRecordNode()->
-                    setChannelStatus(ch, status);
+                setChannelStatus(ch, status);
             }
             else     // change parameter directly
             {
@@ -869,7 +869,7 @@ void ChannelSelectorRegion::mouseWheelMove(const MouseEvent& event,
                                            const MouseWheelDetails& wheel)
 {
 
-   // std::cout << "Got wheel move: " << wheel.deltaY << std::endl;
+    // std::cout << "Got wheel move: " << wheel.deltaY << std::endl;
     channelSelector->shiftChannelsVertical(-wheel.deltaY);
 }
 
diff --git a/Source/Processors/Editors/ElectrodeButtons.cpp b/Source/Processors/Editors/ElectrodeButtons.cpp
index d6506fbce7f41b2c1508582a57b95935fc1bde5c..b7b9b6583705544da0f306e05545c19cfc8a586b 100644
--- a/Source/Processors/Editors/ElectrodeButtons.cpp
+++ b/Source/Processors/Editors/ElectrodeButtons.cpp
@@ -33,8 +33,8 @@ void ElectrodeButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDo
     if (isMouseOver)
         g.setColour(Colours::white);
 
-	if (!isEnabled())
-		g.setColour(Colours::black);
+    if (!isEnabled())
+        g.setColour(Colours::black);
 
     g.fillRect(0,0,getWidth(),getHeight());
 
@@ -43,28 +43,28 @@ void ElectrodeButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDo
 
     g.drawRect(0,0,getWidth(),getHeight(),1.0);
 
-	if (!isEnabled())
-	{
-		g.setColour(Colours::grey);
-	}
+    if (!isEnabled())
+    {
+        g.setColour(Colours::grey);
+    }
 
     if (chan >= 0)
-		g.drawText(getButtonText(),0,0,getWidth(),getHeight(),Justification::centred,true);
+        g.drawText(getButtonText(),0,0,getWidth(),getHeight(),Justification::centred,true);
 }
 
 void ElectrodeButton::setChannelNum(int i)
 {
-		setChannelNum(i,true);
+    setChannelNum(i,true);
 }
 
 void ElectrodeButton::setChannelNum(int i, bool changeButtonText)
 {
-	chan = i;
+    chan = i;
 
-	if (changeButtonText)
-	{
-		setButtonText(String(chan));
-	}
+    if (changeButtonText)
+    {
+        setButtonText(String(chan));
+    }
 }
 
 
diff --git a/Source/Processors/Editors/ElectrodeButtons.h b/Source/Processors/Editors/ElectrodeButtons.h
index 800e1dafe1af9be116fdc8c8fde295fdbfda4953..00b3f0427593fb5888564102a9f1321c2855d17b 100644
--- a/Source/Processors/Editors/ElectrodeButtons.h
+++ b/Source/Processors/Editors/ElectrodeButtons.h
@@ -42,7 +42,7 @@ public:
         setClickingTogglesState(true);
         //setRadioGroupId(299);
         setToggleState(true, dontSendNotification);
-		setButtonText(String(chan_));
+        setButtonText(String(chan_));
     }
     ~ElectrodeButton() {}
 
@@ -51,7 +51,7 @@ public:
         return chan;
     }
     void setChannelNum(int i);
-	void setChannelNum(int i, bool changeButtonText);
+    void setChannelNum(int i, bool changeButtonText);
 
 
 private:
diff --git a/Source/Processors/Editors/FilterEditor.cpp b/Source/Processors/Editors/FilterEditor.cpp
index 0046cf09f3e7a30026877616ae0092642b305465..6609141f87ae08c6358f9de7cabc56c6b418d1b0 100755
--- a/Source/Processors/Editors/FilterEditor.cpp
+++ b/Source/Processors/Editors/FilterEditor.cpp
@@ -67,7 +67,7 @@ FilterEditor::FilterEditor(GenericProcessor* parentNode, bool useDefaultParamete
     highCutValue->setTooltip("Set the high cut for the selected channels");
     addAndMakeVisible(highCutValue);
 
-	applyFilterOnADC = new UtilityButton("+ADCs",Font("Default", 10, Font::plain));
+    applyFilterOnADC = new UtilityButton("+ADCs",Font("Default", 10, Font::plain));
     applyFilterOnADC->addListener(this);
     applyFilterOnADC->setBounds(90,70,40,18);
     applyFilterOnADC->setClickingTogglesState(true);
@@ -81,13 +81,13 @@ FilterEditor::FilterEditor(GenericProcessor* parentNode, bool useDefaultParamete
     applyFilterOnChan->setToggleState(true, dontSendNotification);
     applyFilterOnChan->setTooltip("When this button is off, selected channels will not be filtered");
     addAndMakeVisible(applyFilterOnChan);
- 
+
 }
 
 FilterEditor::~FilterEditor()
 {
-    
-}   
+
+}
 
 void FilterEditor::setDefaults(double lowCut, double highCut)
 {
@@ -106,19 +106,19 @@ void FilterEditor::labelTextChanged(Label* label)
     Value val = label->getTextValue();
     double requestedValue = double(val.getValue());
 
-    if (requestedValue < 0.01 || requestedValue > 10000) 
+    if (requestedValue < 0.01 || requestedValue > 10000)
     {
         sendActionMessage("Value out of range.");
 
         if (label == highCutValue)
         {
             label->setText(lastHighCutString, dontSendNotification);
-			lastHighCutString = label->getText();
+            lastHighCutString = label->getText();
         }
         else
         {
             label->setText(lastLowCutString, dontSendNotification);
-			lastLowCutString = label->getText();
+            lastLowCutString = label->getText();
         }
 
         return;
@@ -180,7 +180,8 @@ void FilterEditor::buttonEvent(Button* button)
         FilterNode* fn = (FilterNode*) getProcessor();
         fn->setApplyOnADC(applyFilterOnADC->getToggleState());
 
-    } else if (button == applyFilterOnChan)
+    }
+    else if (button == applyFilterOnChan)
     {
         FilterNode* fn = (FilterNode*) getProcessor();
 
@@ -208,7 +209,7 @@ void FilterEditor::saveCustomParameters(XmlElement* xml)
     XmlElement* textLabelValues = xml->createNewChildElement("VALUES");
     textLabelValues->setAttribute("HighCut",lastHighCutString);
     textLabelValues->setAttribute("LowCut",lastLowCutString);
-	textLabelValues->setAttribute("ApplyToADC",	applyFilterOnADC->getToggleState());
+    textLabelValues->setAttribute("ApplyToADC",	applyFilterOnADC->getToggleState());
 }
 
 void FilterEditor::loadCustomParameters(XmlElement* xml)
@@ -220,7 +221,7 @@ void FilterEditor::loadCustomParameters(XmlElement* xml)
         {
             highCutValue->setText(xmlNode->getStringAttribute("HighCut"),dontSendNotification);
             lowCutValue->setText(xmlNode->getStringAttribute("LowCut"),dontSendNotification);
-			applyFilterOnADC->setToggleState(xmlNode->getBoolAttribute("ApplyToADC",false), sendNotification);
+            applyFilterOnADC->setToggleState(xmlNode->getBoolAttribute("ApplyToADC",false), sendNotification);
         }
     }
 
diff --git a/Source/Processors/Editors/FilterEditor.h b/Source/Processors/Editors/FilterEditor.h
index 58945523e182ceaf3ac40c6270526b85a7f3e7e1..d691ad6f3793db445c3490278a5dbac7233e5eb4 100755
--- a/Source/Processors/Editors/FilterEditor.h
+++ b/Source/Processors/Editors/FilterEditor.h
@@ -39,7 +39,7 @@ class FilterViewport;
 */
 
 class FilterEditor : public GenericEditor,
-	public Label::Listener
+    public Label::Listener
 {
 public:
     FilterEditor(GenericProcessor* parentNode, bool useDefaultParameterEditors);
@@ -65,7 +65,7 @@ private:
 
     ScopedPointer<Label> highCutValue;
     ScopedPointer<Label> lowCutValue;
-	ScopedPointer<UtilityButton> applyFilterOnADC;
+    ScopedPointer<UtilityButton> applyFilterOnADC;
     ScopedPointer<UtilityButton> applyFilterOnChan;
 
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FilterEditor);
diff --git a/Source/Processors/Editors/GenericEditor.cpp b/Source/Processors/Editors/GenericEditor.cpp
index 56b51eb8757c822d135545f7538da96c0889ee6c..2d5bbb1b7479f3ab145230d4510919df60ec4a85 100755
--- a/Source/Processors/Editors/GenericEditor.cpp
+++ b/Source/Processors/Editors/GenericEditor.cpp
@@ -35,7 +35,7 @@
 
 #ifndef M_PI
 #define M_PI 3.14159265359
-#endif 
+#endif
 GenericEditor::GenericEditor(GenericProcessor* owner, bool useDefaultParameterEditors=true)
     : AudioProcessorEditor(owner),
       desiredWidth(150), isFading(false), accumulator(0.0), acquisitionIsActive(false),
@@ -76,7 +76,7 @@ void GenericEditor::constructorInitialize(GenericProcessor* owner, bool useDefau
 
     if (!owner->isMerger() && !owner->isSplitter() && !owner->isUtility())
     {
-       // std::cout << "Adding drawer button." << std::endl;
+        // std::cout << "Adding drawer button." << std::endl;
 
         drawerButton = new DrawerButton("name");
         drawerButton->addListener(this);
@@ -141,7 +141,7 @@ void GenericEditor::addParameterEditors(bool useDefaultParameterEditors=true)
         int maxX = 15;
         int maxY = 30;
 
-       // std::cout << "Adding parameter editors." << std::endl;
+        // std::cout << "Adding parameter editors." << std::endl;
 
         for (int i = 0; i < getProcessor()->getNumParameters(); i++)
         {
@@ -372,12 +372,14 @@ void GenericEditor::paint(Graphics& g)
     // draw title
     if (!isCollapsed)
     {
-       // if (!getProcessor()->isMerger() && !getProcessor()->isSplitter())
-      //      g.drawText(name+" ("+String(nodeId)+")", 6, 5, 500, 15, Justification::left, false);
-       // else
-            g.drawText(displayName, 6, 5, 500, 15, Justification::left, false);
+        // if (!getProcessor()->isMerger() && !getProcessor()->isSplitter())
+        //      g.drawText(name+" ("+String(nodeId)+")", 6, 5, 500, 15, Justification::left, false);
+        // else
+        g.drawText(displayName, 6, 5, 500, 15, Justification::left, false);
 
-    } else {
+    }
+    else
+    {
         g.addTransform(AffineTransform::rotation(-M_PI/2.0));
         g.drawText(displayName, -getHeight()+6, 5, 500, 15, Justification::left, false);
         g.addTransform(AffineTransform::rotation(M_PI/2.0));
@@ -423,7 +425,7 @@ void GenericEditor::timerCallback()
 void GenericEditor::buttonClicked(Button* button)
 {
 
-   // std::cout << "Button clicked." << std::endl;
+    // std::cout << "Button clicked." << std::endl;
 
     checkDrawerButton(button);
 
@@ -482,7 +484,7 @@ void GenericEditor::update()
 
     GenericProcessor* p = (GenericProcessor*) getProcessor();
 
-   // std::cout << p->getName() << " updating settings." << std::endl;
+    // std::cout << p->getName() << " updating settings." << std::endl;
 
     int numChannels;
 
@@ -497,7 +499,7 @@ void GenericEditor::update()
 
         for (int i = 0; i < numChannels; i++)
         {
-           // std::cout << p->channels[i]->getRecordState() << std::endl;
+            // std::cout << p->channels[i]->getRecordState() << std::endl;
             channelSelector->setRecordStatus(i, p->channels[i]->getRecordState());
         }
     }
@@ -630,7 +632,9 @@ void GenericEditor::switchCollapsedState()
             desiredWidth = originalWidth;
             isCollapsed = false;
 
-        } else {
+        }
+        else
+        {
             originalWidth = desiredWidth;
             desiredWidth = 25;
             isCollapsed = true;
@@ -682,9 +686,9 @@ void GenericEditor::loadEditorParameters(XmlElement* xml)
 
 GenericEditor* GenericEditor::getSourceEditor()
 {
-    
+
     GenericProcessor* sourceNode = getProcessor()->getSourceNode();
-    
+
     if (sourceNode != nullptr)
         return sourceNode->getEditor();
     else
@@ -694,7 +698,7 @@ GenericEditor* GenericEditor::getSourceEditor()
 GenericEditor* GenericEditor::getDestEditor()
 {
     GenericProcessor* destNode = getProcessor()->getDestNode();
-    
+
     if (destNode != nullptr)
         return destNode->getEditor();
     else
@@ -932,7 +936,7 @@ void UtilityButton::resized()
 
 String UtilityButton::getLabel()
 {
-	return label;
+    return label;
 }
 
 void UtilityButton::setLabel(String label_)
diff --git a/Source/Processors/Editors/GenericEditor.h b/Source/Processors/Editors/GenericEditor.h
index 56c4177b89fee3129f32b97145424d99a31f809b..ed1ce7e3745b064c84b6e01c5c026b5362f1a3b6 100755
--- a/Source/Processors/Editors/GenericEditor.h
+++ b/Source/Processors/Editors/GenericEditor.h
@@ -86,7 +86,7 @@ public:
 
     /** Highlights an editor.*/
     void highlight();
-    
+
     /** Makes an editor visible if it's not already.*/
     void makeVisible();
 
@@ -176,21 +176,24 @@ public:
 
     /** Required for SplitterEditor only.*/
     virtual void switchDest() { }
-    
+
 
     /** Required for SplitterEditor and MergerEditor only.*/
     virtual void switchIO(int) { }
-    
+
     /** Required for SplitterEditor and MergerEditor only.*/
-    virtual int getPathForEditor(GenericEditor* editor) { return -1;}
-    
+    virtual int getPathForEditor(GenericEditor* editor)
+    {
+        return -1;
+    }
+
     /** Used by GraphViewer */
     bool isSplitter();
-    
+
     /** Used by GraphViewer */
     bool isMerger();
-    
-    
+
+
 
     /** Handles button clicks for all editors. Deals with clicks on the editor's
         title bar and channel selector drawer. */
@@ -282,21 +285,25 @@ public:
     /**  Collapses an editor if it's open, and opens it if it's collpased*/
     void switchCollapsedState();
 
-     /**  Notifies the editor that the collapsed state changed, for non-standard function. */
+    /**  Notifies the editor that the collapsed state changed, for non-standard function. */
     virtual void collapsedStateChanged() {}
 
     /** Returns the editor of this processor's source */
     GenericEditor* getSourceEditor();
-    
+
     /** Returns the editor of this processor's destination */
     GenericEditor* getDestEditor();
 
     /** Returns the editors a splitter or merger is connected to */
-	virtual Array<GenericEditor*> getConnectedEditors(){ Array<GenericEditor*> a; return a;}
+    virtual Array<GenericEditor*> getConnectedEditors()
+    {
+        Array<GenericEditor*> a;
+        return a;
+    }
 
     /** Returns an array of record statuses for all channels. Used by GraphNode */
     Array<bool> getRecordStatusArray();
-    
+
 protected:
 
     /** A pointer to the button that opens the drawer for the ChannelSelector. */
@@ -421,7 +428,7 @@ public:
     }
 
     void setLabel(String label);
-	String getLabel();
+    String getLabel();
 
 private:
     void paintButton(Graphics& g, bool isMouseOver, bool isButtonDown);
diff --git a/Source/Processors/Editors/MergerEditor.cpp b/Source/Processors/Editors/MergerEditor.cpp
index 5687ba224c2d58ac0ce2bfcbebca153e78fab788..72d37a07fd8c3ca1ea24f4b5a52c158d647208c5 100755
--- a/Source/Processors/Editors/MergerEditor.cpp
+++ b/Source/Processors/Editors/MergerEditor.cpp
@@ -133,7 +133,7 @@ void MergerEditor::mouseDown(const MouseEvent& e)
 
         for (int i = 0; i < availableProcessors.size(); i++)
         {
-            if (!availableProcessors[i]->isSink() && 
+            if (!availableProcessors[i]->isSink() &&
                 !availableProcessors[i]->isMerger() &&
                 !availableProcessors[i]->isSplitter() &&
                 availableProcessors[i]->getDestNode() != getProcessor())
@@ -153,7 +153,7 @@ void MergerEditor::mouseDown(const MouseEvent& e)
         if (result > 1)
         {
             std::cout << "Selected " << availableProcessors[result-2]->getName() << std::endl;
-        
+
             switchSource(1);
 
             Merger* processor = (Merger*) getProcessor();
@@ -166,7 +166,7 @@ void MergerEditor::mouseDown(const MouseEvent& e)
         }
     }
 
-    
+
 
 }
 
@@ -196,7 +196,7 @@ Array<GenericEditor*> MergerEditor::getConnectedEditors()
     Array<GenericEditor*> editors;
 
     Merger* processor = (Merger*) getProcessor();
-    
+
     for (int pathNum = 0; pathNum < 2; pathNum++)
     {
         processor->switchIO();
@@ -206,7 +206,7 @@ Array<GenericEditor*> MergerEditor::getConnectedEditors()
         else
             editors.add(nullptr);
     }
-    
+
     return editors;
 
 }
@@ -214,18 +214,18 @@ Array<GenericEditor*> MergerEditor::getConnectedEditors()
 int MergerEditor::getPathForEditor(GenericEditor* editor)
 {
     Merger* processor = (Merger*) getProcessor();
-    
+
     for (int pathNum = 0; pathNum < 2; pathNum++)
     {
-    switchSource(pathNum);
-    
-    if (processor->getSourceNode() != nullptr)
-    {
-        if (processor->getEditor() == editor)
-            return pathNum;
-    }
+        switchSource(pathNum);
+
+        if (processor->getSourceNode() != nullptr)
+        {
+            if (processor->getEditor() == editor)
+                return pathNum;
+        }
     }
-    
+
     return -1;
 
 }
diff --git a/Source/Processors/Editors/MergerEditor.h b/Source/Processors/Editors/MergerEditor.h
index 654889677b2cde4e0a8293dff1a53ca115673035..a9b6b7b3d95192974bac4bf43109be23b2b0523c 100755
--- a/Source/Processors/Editors/MergerEditor.h
+++ b/Source/Processors/Editors/MergerEditor.h
@@ -51,7 +51,7 @@ public:
     void switchIO(int);
 
     void mouseDown(const MouseEvent& event);
-    
+
     int getPathForEditor(GenericEditor* editor);
 
     Array<GenericEditor*> getConnectedEditors();
diff --git a/Source/Processors/Editors/ParameterEditor.cpp b/Source/Processors/Editors/ParameterEditor.cpp
index 6e4cf7b4847feb50ea0d5e62c9699c1487701581..9c139e065078e8b1c607db7e5423fa8eb730f261 100755
--- a/Source/Processors/Editors/ParameterEditor.cpp
+++ b/Source/Processors/Editors/ParameterEditor.cpp
@@ -426,7 +426,7 @@ void ParameterCheckbox::paintButton(Graphics& g, bool isMouseOver, bool isButton
         g.setGradientFill(deactivatedGrad);
     }
 
-   // AffineTransform a = AffineTransform::scale(0.98f, 0.94f, float(getWidth())/2.0f,
+    // AffineTransform a = AffineTransform::scale(0.98f, 0.94f, float(getWidth())/2.0f,
     //                                           float(getHeight())/2.0f);
 
     g.fillRoundedRectangle(1, 1, getWidth()-2, getHeight()-2, 2.0f);
diff --git a/Source/Processors/Editors/PhaseDetectorEditor.cpp b/Source/Processors/Editors/PhaseDetectorEditor.cpp
index 275cfd46aeb4cc5e74570845c86e9bde7a57d52f..2e26307e7a5916d5def2779c32e6ffc5f880523f 100644
--- a/Source/Processors/Editors/PhaseDetectorEditor.cpp
+++ b/Source/Processors/Editors/PhaseDetectorEditor.cpp
@@ -75,7 +75,7 @@ PhaseDetectorEditor::PhaseDetectorEditor(GenericProcessor* parentNode, bool useD
     backgroundColours.add(Colours::blue);
 
     plusButton->setToggleState(true, sendNotification);
-    
+
     //interfaces.clear();
 
 }
@@ -110,10 +110,12 @@ void PhaseDetectorEditor::comboBoxChanged(ComboBox* c)
         if (i == c->getSelectedId()-1)
         {
             interfaces[i]->setVisible(true);
-        } else {
+        }
+        else
+        {
             interfaces[i]->setVisible(false);
         }
-        
+
     }
 
 }
@@ -146,7 +148,7 @@ void PhaseDetectorEditor::addDetector()
 
     String itemName = "Detector ";
     itemName += detectorNumber;
-    
+
     //jassert detectorNumber == 1;
 
     //std::cout << itemName << std::endl;
@@ -215,7 +217,7 @@ DetectorInterface::DetectorInterface(PhaseDetector* pd, Colour c, int id) :
     sineWave.startNewSubPath(5,35);
 
     std::cout << "Creating sine wave" << std::endl;
-    
+
     for (double i = 0; i < 2*PI; i += PI/10)
     {
         sineWave.lineTo(i*12 + 5.0f, -sin(i)*20 + 35);
@@ -224,7 +226,7 @@ DetectorInterface::DetectorInterface(PhaseDetector* pd, Colour c, int id) :
     sineWave.addEllipse(2,35,4,4);
 
     std::cout << "Creating phase buttons" << std::endl;
-    
+
     for (int phase = 0; phase < 4; phase++)
     {
         ElectrodeButton* phaseButton = new ElectrodeButton(-1);
@@ -236,12 +238,12 @@ DetectorInterface::DetectorInterface(PhaseDetector* pd, Colour c, int id) :
         phaseButton->setRadioGroupId(12);
         phaseButton->addListener(this);
         phaseButtons.add(phaseButton);
-        addAndMakeVisible(phaseButton); 
+        addAndMakeVisible(phaseButton);
     }
 
     std::cout << "Creating combo boxes" << std::endl;
 
-    
+
     inputSelector = new ComboBox();
     inputSelector->setBounds(140,5,50,20);
     inputSelector->addItem("-",1);
@@ -253,7 +255,7 @@ DetectorInterface::DetectorInterface(PhaseDetector* pd, Colour c, int id) :
     gateSelector->setBounds(140,30,50,20);
     gateSelector->addItem("-",1);
     gateSelector->addListener(this);
-    
+
     std::cout << "Populating combo boxes" << std::endl;
 
 
@@ -277,14 +279,14 @@ DetectorInterface::DetectorInterface(PhaseDetector* pd, Colour c, int id) :
     outputSelector->setSelectedId(1);
     addAndMakeVisible(outputSelector);
 
-    
+
     std::cout << "Updating channels" << std::endl;
-    
+
     updateChannels(processor->getNumInputs());
 
     std::cout << "Updating processor" << std::endl;
 
-    
+
     processor->addModule();
 
 }
@@ -304,10 +306,12 @@ void DetectorInterface::comboBoxChanged(ComboBox* c)
     if (c == inputSelector)
     {
         parameterIndex = 2;
-    } else if (c == outputSelector)
+    }
+    else if (c == outputSelector)
     {
         parameterIndex = 3;
-    } else if (c == gateSelector)
+    }
+    else if (c == gateSelector)
     {
         parameterIndex = 4;
     }
@@ -336,7 +340,7 @@ void DetectorInterface::updateChannels(int numChannels)
     inputSelector->clear();
 
     inputSelector->addItem("-", 1);
-    
+
     if (numChannels > 2048) // channel count hasn't been updated yet
     {
         return;
@@ -383,7 +387,7 @@ void DetectorInterface::setPhase(int p)
 
     if (p >= 0)
         phaseButtons[p]->setToggleState(true, dontSendNotification);
-    
+
 
     processor->setActiveModule(idNum);
 
diff --git a/Source/Processors/Editors/PhaseDetectorEditor.h b/Source/Processors/Editors/PhaseDetectorEditor.h
index 6c0d82c66743fce1158b3d91dc889164c49b57da..f7bafda19202ff40aae12557a9fd0ac74d48007c 100644
--- a/Source/Processors/Editors/PhaseDetectorEditor.h
+++ b/Source/Processors/Editors/PhaseDetectorEditor.h
@@ -47,9 +47,9 @@ class PhaseDetectorEditor : public GenericEditor,
 {
 public:
     PhaseDetectorEditor(GenericProcessor* parentNode, bool useDefaultParameterEditors);
-    
+
     virtual ~PhaseDetectorEditor();
-    
+
     void buttonEvent(Button* button);
 
     void comboBoxChanged(ComboBox* c);
@@ -61,11 +61,11 @@ public:
 
 private:
 
-	ScopedPointer<ComboBox> detectorSelector;
+    ScopedPointer<ComboBox> detectorSelector;
 
-	ScopedPointer<UtilityButton> plusButton;
+    ScopedPointer<UtilityButton> plusButton;
 
-	void addDetector();
+    void addDetector();
 
     // ScopedPointer<ComboBox> inputChannelSelectionBox;
     // ScopedPointer<ComboBox> outputChannelSelectionBox;
@@ -84,46 +84,46 @@ private:
 };
 
 class DetectorInterface : public Component,
-						  public ComboBox::Listener,
-						  public Button::Listener
+    public ComboBox::Listener,
+    public Button::Listener
 {
 public:
-	DetectorInterface(PhaseDetector*, Colour, int);
-	~DetectorInterface();
+    DetectorInterface(PhaseDetector*, Colour, int);
+    ~DetectorInterface();
 
-	void paint(Graphics& g);
+    void paint(Graphics& g);
 
-	void comboBoxChanged(ComboBox*);
-	void buttonClicked(Button*);
+    void comboBoxChanged(ComboBox*);
+    void buttonClicked(Button*);
 
-	void updateChannels(int);
+    void updateChannels(int);
 
-	void setPhase(int);
-	void setInputChan(int);
-	void setOutputChan(int);
-	void setGateChan(int);
+    void setPhase(int);
+    void setInputChan(int);
+    void setOutputChan(int);
+    void setGateChan(int);
 
-	int getPhase();
-	int getInputChan();
-	int getOutputChan();
-	int getGateChan();
+    int getPhase();
+    int getInputChan();
+    int getOutputChan();
+    int getGateChan();
 
 private:
 
-	Colour backgroundColour;
+    Colour backgroundColour;
 
-	Path sineWave;
-	Font font;
+    Path sineWave;
+    Font font;
 
-	int idNum;
+    int idNum;
 
-	PhaseDetector* processor;
+    PhaseDetector* processor;
 
-	OwnedArray<ElectrodeButton> phaseButtons;
+    OwnedArray<ElectrodeButton> phaseButtons;
 
-	ScopedPointer<ComboBox> inputSelector;
-	ScopedPointer<ComboBox> gateSelector;
-	ScopedPointer<ComboBox> outputSelector;
+    ScopedPointer<ComboBox> inputSelector;
+    ScopedPointer<ComboBox> gateSelector;
+    ScopedPointer<ComboBox> outputSelector;
 
 };
 
diff --git a/Source/Processors/Editors/PulsePalOutputEditor.cpp b/Source/Processors/Editors/PulsePalOutputEditor.cpp
index 7f6d44b064131fe4fb28ad90146963ba247db3a5..443d5a8aec31525ea3d8ded3f67241fc37f180b2 100644
--- a/Source/Processors/Editors/PulsePalOutputEditor.cpp
+++ b/Source/Processors/Editors/PulsePalOutputEditor.cpp
@@ -68,7 +68,7 @@ void PulsePalOutputEditor::saveCustomParameters(XmlElement* xml)
         outputXml->setAttribute("Gate",channelTriggerInterfaces[i]->getGateChannel());
     }
 
-    
+
 }
 
 void PulsePalOutputEditor::loadCustomParameters(XmlElement* xml)
@@ -108,7 +108,7 @@ ChannelTriggerInterface::ChannelTriggerInterface(PulsePal* pp, PulsePalOutput* p
 
     for (int i = 0; i < 10; i++)
         triggerSelector->addItem(String(i+1),i+2); // start numbering at one for
-                                                   // user-visible channels
+    // user-visible channels
 
     triggerSelector->setSelectedId(1, dontSendNotification);
     addAndMakeVisible(triggerSelector);
@@ -120,7 +120,7 @@ ChannelTriggerInterface::ChannelTriggerInterface(PulsePal* pp, PulsePalOutput* p
 
     for (int i = 0; i < 10; i++)
         gateSelector->addItem(String(i+1),i+2); // start numbering at one for
-                                                // user-visible channels
+    // user-visible channels
 
     gateSelector->setSelectedId(1, dontSendNotification);
     addAndMakeVisible(gateSelector);
diff --git a/Source/Processors/Editors/RHD2000Editor.cpp b/Source/Processors/Editors/RHD2000Editor.cpp
index 48673ebc15c4da0f16bb8dabc43e58a47b142658..f5a1da51519374e7876e528607c4ec9de4b32cba 100644
--- a/Source/Processors/Editors/RHD2000Editor.cpp
+++ b/Source/Processors/Editors/RHD2000Editor.cpp
@@ -75,15 +75,17 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode,
 
         addAndMakeVisible(button);
         button->addListener(this);
-        
+
         if (i == 0)
         {
             button->setTooltip("Audio monitor left channel");
-        } else {
+        }
+        else
+        {
             button->setTooltip("Audio monitor right channel");
         }
     }
-    
+
 
     audioLabel = new Label("audio label", "Audio out");
     audioLabel->setBounds(180,25,75,15);
@@ -95,8 +97,8 @@ RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode,
     audioInterface = new AudioInterface(board, this);
     addAndMakeVisible(audioInterface);
     audioInterface->setBounds(165, 65, 65, 50);
-    
-    
+
+
     adcButton = new UtilityButton("ADC 1-8", Font("Small Text", 13, Font::plain));
     adcButton->setRadius(3.0f);
     adcButton->setBounds(165,100,65,18);
@@ -156,7 +158,7 @@ void RHD2000Editor::channelChanged(int chan)
             electrodeButtons[i]->setChannelNum(chan);
             electrodeButtons[i]->repaint();
 
-            board->assignAudioOut(i, chan-1); 
+            board->assignAudioOut(i, chan-1);
         }
     }
 }
@@ -187,15 +189,15 @@ void RHD2000Editor::stopAcquisition()
 
 void RHD2000Editor::saveCustomParameters(XmlElement* xml)
 {
-     xml->setAttribute("SampleRate", sampleRateInterface->getSelectedId());
-     xml->setAttribute("LowCut", bandwidthInterface->getLowerBandwidth());
-     xml->setAttribute("HighCut", bandwidthInterface->getUpperBandwidth());
-     xml->setAttribute("ADCsOn", adcButton->getToggleState());
+    xml->setAttribute("SampleRate", sampleRateInterface->getSelectedId());
+    xml->setAttribute("LowCut", bandwidthInterface->getLowerBandwidth());
+    xml->setAttribute("HighCut", bandwidthInterface->getUpperBandwidth());
+    xml->setAttribute("ADCsOn", adcButton->getToggleState());
 }
 
 void RHD2000Editor::loadCustomParameters(XmlElement* xml)
 {
-    
+
     sampleRateInterface->setSelectedId(xml->getIntAttribute("SampleRate"));
     bandwidthInterface->setLowerBandwidth(xml->getDoubleAttribute("LowCut"));
     bandwidthInterface->setUpperBandwidth(xml->getDoubleAttribute("HighCut"));
@@ -578,29 +580,29 @@ void HeadstageOptionsInterface::paint(Graphics& g)
 // (Direct OpalKelly) Audio Options --------------------------------------------------------------------
 
 AudioInterface::AudioInterface(RHD2000Thread* board_,
-                                       RHD2000Editor* editor_) :
-board(board_), editor(editor_)
+                               RHD2000Editor* editor_) :
+    board(board_), editor(editor_)
 {
-    
+
     name = "Noise Slicer";
-    
+
     lastNoiseSlicerString = "0";
-    
+
     actualNoiseSlicerLevel = 0.0f;
-    
+
     noiseSlicerLevelSelection = new Label("Noise Slicer",lastNoiseSlicerString); // this is currently set in RHD2000Thread, the cleaner would be to set it here again
     noiseSlicerLevelSelection->setEditable(true,false,false);
     noiseSlicerLevelSelection->addListener(this);
     noiseSlicerLevelSelection->setBounds(30,10,30,20);
     noiseSlicerLevelSelection->setColour(Label::textColourId, Colours::darkgrey);
     addAndMakeVisible(noiseSlicerLevelSelection);
-    
-    
+
+
 }
 
 AudioInterface::~AudioInterface()
 {
-    
+
 }
 
 
@@ -610,27 +612,28 @@ void AudioInterface::labelTextChanged(Label* label)
     {
         if (label == noiseSlicerLevelSelection)
         {
-            
+
             Value val = label->getTextValue();
             int requestedValue = int(val.getValue()); // Note that it might be nice to translate to actual uV levels (16*value)
-            
+
             if (requestedValue < 0 || requestedValue > 127)
             {
                 editor->sendActionMessage("Value out of range.");
-                
+
                 label->setText(lastNoiseSlicerString, dontSendNotification);
-                
+
                 return;
             }
-            
+
             actualNoiseSlicerLevel = board->setNoiseSlicerLevel(requestedValue);
-            
+
             std::cout << "Setting Noise Slicer Level to " << requestedValue << std::endl;
             label->setText(String((roundFloatToInt)(actualNoiseSlicerLevel)), dontSendNotification);
 
         }
     }
-    else {
+    else
+    {
         Value val = label->getTextValue();
         int requestedValue = int(val.getValue()); // Note that it might be nice to translate to actual uV levels (16*value)
         if (requestedValue < 0 || requestedValue > 127)
@@ -656,15 +659,15 @@ int AudioInterface::getNoiseSlicerLevel()
 
 void AudioInterface::paint(Graphics& g)
 {
-    
+
     g.setColour(Colours::darkgrey);
-    
+
     g.setFont(Font("Small Text",9,Font::plain));
-    
+
     g.drawText(name, 0, 0, 200, 15, Justification::left, false);
-    
+
     g.drawText("Level: ", 0, 10, 200, 20, Justification::left, false);
-    
+
 }
 
 
diff --git a/Source/Processors/Editors/RHD2000Editor.h b/Source/Processors/Editors/RHD2000Editor.h
index aa0f2b27210639b6714e263f4c843c170784a38b..c7413a13b3f67ba7e297444a830fa9a62951d6ef 100644
--- a/Source/Processors/Editors/RHD2000Editor.h
+++ b/Source/Processors/Editors/RHD2000Editor.h
@@ -177,36 +177,36 @@ private:
 };
 
 class AudioInterface : public Component,
-public Label::Listener
+    public Label::Listener
 {
 public:
     AudioInterface(RHD2000Thread*, RHD2000Editor*);
     ~AudioInterface();
-    
+
     void paint(Graphics& g);
     void labelTextChanged(Label* te);
-    
+
     void setNoiseSlicerLevel(int value);
     int getNoiseSlicerLevel();
     //void setGain(double value);
     //double getGain();
-    
+
 private:
-    
+
     String name;
-    
+
     String lastNoiseSlicerString;
     String lastGainString;
-    
+
     RHD2000Thread* board;
     RHD2000Editor* editor;
-    
+
     ScopedPointer<Label> noiseSlicerLevelSelection;
     //ScopedPointer<Label> gainSelection;
-    
+
     int actualNoiseSlicerLevel;
     //double actualGain;
-    
+
 };
 
 
diff --git a/Source/Processors/Editors/RecordControlEditor.cpp b/Source/Processors/Editors/RecordControlEditor.cpp
index 98408e244fccbcf58a1e0aad2023007e21f72780..e97638e92e7ef4e9c97f9d67a6d9c47c78b12584 100644
--- a/Source/Processors/Editors/RecordControlEditor.cpp
+++ b/Source/Processors/Editors/RecordControlEditor.cpp
@@ -50,7 +50,7 @@ RecordControlEditor::RecordControlEditor(GenericProcessor* parentNode, bool useD
     availableChans->setSelectedId(0);
 
     addAndMakeVisible(availableChans);
-    
+
     availableChans->addItem("None",1);
     for (int i = 0; i < 10 ; i++)
     {
@@ -58,7 +58,7 @@ RecordControlEditor::RecordControlEditor(GenericProcessor* parentNode, bool useD
         channelName += i + 1;
         availableChans->addItem(channelName,i+2);
     }
-    
+
     newFileToggleButton = new UtilityButton("SPLIT FILES", Font("Small Text", 13, Font::plain));
     newFileToggleButton->setRadius(3.0f);
     newFileToggleButton->setBounds(35, 95, 90, 18);
@@ -70,7 +70,7 @@ RecordControlEditor::RecordControlEditor(GenericProcessor* parentNode, bool useD
 
 RecordControlEditor::~RecordControlEditor()
 {
-    
+
 }
 
 void RecordControlEditor::comboBoxChanged(ComboBox* comboBox)
@@ -88,7 +88,9 @@ void RecordControlEditor::buttonEvent(Button* button)
     if (button->getToggleState())
     {
         getProcessor()->setParameter(1, 1.0f);
-    } else {
+    }
+    else
+    {
         getProcessor()->setParameter(1, 0.0f);
     }
 }
@@ -97,27 +99,27 @@ void RecordControlEditor::updateSettings()
 {
     //availableChans->clear();
     //GenericProcessor* processor = getProcessor();
-    
+
 
 }
 
-void RecordControlEditor::saveEditorParameters(XmlElement* xml)
+void RecordControlEditor::saveCustomParameters(XmlElement* xml)
 {
-    
+
     XmlElement* info = xml->createNewChildElement("PARAMETERS");
-    
+
     info->setAttribute("Type", "RecordControlEditor");
     info->setAttribute("Channel",availableChans->getSelectedId());
     info->setAttribute("FileSaveOption",newFileToggleButton->getToggleState());
-    
+
 }
 
-void RecordControlEditor::loadEditorParameters(XmlElement* xml)
+void RecordControlEditor::loadCustomParameters(XmlElement* xml)
 {
-     
+
     forEachXmlChildElement(*xml, xmlNode)
     {
-        
+
         if (xmlNode->hasTagName("PARAMETERS"))
         {
             newFileToggleButton->setToggleState(xmlNode->getBoolAttribute("FileSaveOption"), sendNotification);
diff --git a/Source/Processors/Editors/RecordControlEditor.h b/Source/Processors/Editors/RecordControlEditor.h
index 4fcc99a6a3ccc4c21c15ad7643cb7e84d02ad0ff..0976ac133237f0e87964658d41e651269175f39c 100644
--- a/Source/Processors/Editors/RecordControlEditor.h
+++ b/Source/Processors/Editors/RecordControlEditor.h
@@ -44,8 +44,8 @@ public:
     void comboBoxChanged(ComboBox* comboBox);
     void updateSettings();
     void buttonEvent(Button* button);
-    void loadEditorParameters(XmlElement*);
-    void saveEditorParameters(XmlElement*);
+    void loadCustomParameters(XmlElement*);
+    void saveCustomParameters(XmlElement*);
 
 private:
     ScopedPointer<ComboBox> availableChans;
diff --git a/Source/Processors/Editors/SerialInputEditor.cpp b/Source/Processors/Editors/SerialInputEditor.cpp
index e7981a1019dcf14b2180b35d34d8bda142718b98..9fbf677b81bc37ae4b31a619e7c469ef8b6a52d6 100644
--- a/Source/Processors/Editors/SerialInputEditor.cpp
+++ b/Source/Processors/Editors/SerialInputEditor.cpp
@@ -1,24 +1,24 @@
 /*
  ------------------------------------------------------------------
- 
+
  This file is part of the Open Ephys GUI
  Copyright (C) 2013 Florian Franzen
- 
+
  ------------------------------------------------------------------
- 
+
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
- 
+
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
- 
+
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- 
+
  */
 
 #include "SerialInputEditor.h"
@@ -29,41 +29,41 @@
 
 
 SerialInputEditor::SerialInputEditor(SerialInput* parentNode)
-: GenericEditor(parentNode, false)
+    : GenericEditor(parentNode, false)
 {
     node = parentNode;
-    
+
     desiredWidth = 180;
-    
+
     // Add device list
     deviceList = new ComboBox();
     deviceList->setBounds(10,30,150,25);
     deviceList->addListener(this);
     deviceList->addItemList(node->getDevices(), 1);
-    
+
     addAndMakeVisible(deviceList);
-    
-    
+
+
     // Add baudrate list
     baudrateList = new ComboBox();
     baudrateList->setBounds(10,60,80,25);
     baudrateList->addListener(this);
-    
+
     Array<int> baudrates = node->getBaudrates();
-    
+
     for (int i = 0; i < baudrates.size(); i++)
     {
         baudrateList->addItem(String(baudrates[i]), baudrates[i]);
     }
-    
+
     addAndMakeVisible(baudrateList);
-    
+
     // Add refresh button
     refreshButton = new UtilityButton("REFRESH", Font("Small Text", 13, Font::bold));
     refreshButton->setRadius(3.0f);
     refreshButton->setBounds(95, 60, 65, 25);
     refreshButton->addListener(this);
-    
+
     addAndMakeVisible(refreshButton);
 }
 
diff --git a/Source/Processors/Editors/SerialInputEditor.h b/Source/Processors/Editors/SerialInputEditor.h
index e0928e1d77784c18af57c18d49ac6e5c1c558b61..ef3fd40c46c5322dce7708c49804a6172a70af6c 100644
--- a/Source/Processors/Editors/SerialInputEditor.h
+++ b/Source/Processors/Editors/SerialInputEditor.h
@@ -1,24 +1,24 @@
 /*
  ------------------------------------------------------------------
- 
+
  This file is part of the Open Ephys GUI
  Copyright (C) 2013 Florian Franzen
- 
+
  ------------------------------------------------------------------
- 
+
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
- 
+
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
- 
+
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- 
+
  */
 
 #ifndef __SERIALINPUTEDITOR_H_A5A233EF__
@@ -35,42 +35,42 @@ class SerialInput;
 
 class SerialInputEditor : public GenericEditor, public ComboBox::Listener
 {
-    
+
 public:
 
     SerialInputEditor(SerialInput* parentNode);
-    
+
     /** Button listener callback, called by button when pressed. */
     void buttonEvent(Button* button);
-    
+
     /** Combobox listener callback, callewd when a combobox is changed. */
     void comboBoxChanged(ComboBox* box);
-    
+
     /** Called by processor graph in beginning of the acqusition, disables editor completly. */
     void startAcquisition();
-    
+
     /** Called by processor graph at the end of the acqusition, reenables editor completly. */
     void stopAcquisition();
 
     /** Called when configuration is saved. Adds editors config to xml. */
     void saveEditorParameters(XmlElement* xml);
-    
+
     /** Called when configuration is loaded. Reads editors config from xml. */
     void loadEditorParameters(XmlElement* xml);
-    
+
 private:
-    
+
     // Button that reloads device list
     ScopedPointer<UtilityButton> refreshButton;
-    
+
     // List of all available dvices
     ScopedPointer<ComboBox> deviceList;
     // List of all available baudrates.
     ScopedPointer<ComboBox> baudrateList;
-    
+
     // Parent node
     SerialInput* node;
-    
+
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SerialInputEditor);
 };
 
diff --git a/Source/Processors/Editors/SpikeDetectorEditor.cpp b/Source/Processors/Editors/SpikeDetectorEditor.cpp
index 1492e2e5ddf42ab4cb34a3f183f63fb135699c4b..da6f70061b6fe3101300ce83c85aa9d57e4374dd 100755
--- a/Source/Processors/Editors/SpikeDetectorEditor.cpp
+++ b/Source/Processors/Editors/SpikeDetectorEditor.cpp
@@ -123,10 +123,10 @@ SpikeDetectorEditor::SpikeDetectorEditor(GenericProcessor* parentNode, bool useD
     // create a custom channel selector
     //deleteAndZero(channelSelector);
 
-   // channelSelector = new ChannelSelector(false, font);
-  //  addChildComponent(channelSelector);
-   // channelSelector->setVisible(false);
-//
+    // channelSelector = new ChannelSelector(false, font);
+    //  addChildComponent(channelSelector);
+    // channelSelector->setVisible(false);
+    //
     //  Array<int> a;
 
     channelSelector->inactivateButtons();
@@ -184,7 +184,7 @@ void SpikeDetectorEditor::buttonEvent(Button* button)
             ElectrodeButton* eb = (ElectrodeButton*) button;
             int electrodeNum = eb->getChannelNum()-1;
 
-           // std::cout << "Channel number: " << electrodeNum << std::endl;
+            // std::cout << "Channel number: " << electrodeNum << std::endl;
             Array<int> a;
             a.add(electrodeNum);
             channelSelector->setActiveChannels(a);
@@ -245,7 +245,7 @@ void SpikeDetectorEditor::buttonEvent(Button* button)
         }
 
         int type = electrodeTypes->getSelectedId();
-       // std::cout << type << std::endl;
+        // std::cout << type << std::endl;
         int nChans;
 
         switch (type)
@@ -354,7 +354,9 @@ void SpikeDetectorEditor::buttonEvent(Button* button)
                 channelSelector->setAudioStatus(channelNum, audioMonitorButton->getToggleState());
 
             }
-        } else {
+        }
+        else
+        {
             audioMonitorButton->setToggleState(false, dontSendNotification);
         }
 
@@ -367,7 +369,7 @@ void SpikeDetectorEditor::buttonEvent(Button* button)
             sendActionMessage("Stop acquisition before deleting electrodes.");
             return;
         }
-    
+
         removeElectrode(electrodeList->getSelectedItemIndex());
 
         getEditorViewport()->makeEditorVisible(this, true, true);
@@ -513,7 +515,7 @@ void SpikeDetectorEditor::comboBoxChanged(ComboBox* comboBox)
 
             processor->setElectrodeName(lastId, comboBox->getText());
             comboBox->changeItemText(lastId, comboBox->getText());
-           //electrodeList->setText(comboBox->getText());
+            //electrodeList->setText(comboBox->getText());
             //refreshElectrodeList();
 
         }
@@ -607,7 +609,7 @@ ThresholdSlider::ThresholdSlider(Font f) : Slider("name"), font(f)
 
     setSliderStyle(Slider::Rotary);
     setRange(25.0f,400.0f,5.0f);
-   // setValue(75.0f);
+    // setValue(75.0f);
     setTextBoxStyle(Slider::NoTextBox, false, 40, 20);
 
 }
diff --git a/Source/Processors/Editors/SpikeDetectorEditor.h b/Source/Processors/Editors/SpikeDetectorEditor.h
index 36363951b957f395d2e86f10c59d2299a052fad7..6a4b44cf375a880399d543e32328e2998ec43b8a 100755
--- a/Source/Processors/Editors/SpikeDetectorEditor.h
+++ b/Source/Processors/Editors/SpikeDetectorEditor.h
@@ -115,7 +115,7 @@ private:
 
     OwnedArray<ElectrodeButton> electrodeButtons;
     Array<ElectrodeEditorButton*> electrodeEditorButtons;
-    
+
     void editElectrode(int index, int chan, int newChan);
 
     int lastId;
diff --git a/Source/Processors/Editors/SpikeDisplayEditor.cpp b/Source/Processors/Editors/SpikeDisplayEditor.cpp
index 13ccd935bf738378d22a65a8bce5844d2d2e0aaf..17bc397322b92b7d23263fe594d2ba24a3c606cf 100755
--- a/Source/Processors/Editors/SpikeDisplayEditor.cpp
+++ b/Source/Processors/Editors/SpikeDisplayEditor.cpp
@@ -184,20 +184,20 @@ Visualizer* SpikeDisplayEditor::createNewCanvas()
 
 void SpikeDisplayEditor::startRecording()
 {
-    
+
     SpikeDisplayCanvas* sdc = (SpikeDisplayCanvas*) canvas.get();
-    
+
     sdc->startRecording();
-    
+
 }
 
 void SpikeDisplayEditor::stopRecording()
 {
-    
+
     SpikeDisplayCanvas* sdc = (SpikeDisplayCanvas*) canvas.get();
-    
+
     sdc->stopRecording();
-    
+
 }
 
 // void SpikeDisplayEditor::updateSettings()
diff --git a/Source/Processors/Editors/SpikeDisplayEditor.h b/Source/Processors/Editors/SpikeDisplayEditor.h
index 0294c6dc63fa4547046dc193c6062af03dde416d..e8b6294df825e9122864772313af42cdc5075b40 100755
--- a/Source/Processors/Editors/SpikeDisplayEditor.h
+++ b/Source/Processors/Editors/SpikeDisplayEditor.h
@@ -52,7 +52,7 @@ public:
     ~SpikeDisplayEditor();
 
     void buttonCallback(Button* button);
-    
+
     void startRecording();
     void stopRecording();
 
diff --git a/Source/Processors/Editors/SplitterEditor.cpp b/Source/Processors/Editors/SplitterEditor.cpp
index 3db8fc8808e3c6505a1f2722a946963f0560f958..f2547482e7c1625c7c337728b81e06d112a676a1 100755
--- a/Source/Processors/Editors/SplitterEditor.cpp
+++ b/Source/Processors/Editors/SplitterEditor.cpp
@@ -151,20 +151,20 @@ void SplitterEditor::switchIO(int dest)
 int SplitterEditor::getPathForEditor(GenericEditor* editor)
 {
     Splitter* processor = (Splitter*) getProcessor();
-    
+
     for (int pathNum = 0; pathNum < 2; pathNum++)
     {
         processor->switchIO();
-        
+
         if (processor->getDestNode() != nullptr)
         {
             if (processor->getDestNode()->getEditor() == editor)
                 return processor->getPath();
         }
     }
-    
+
     return -1;
-    
+
 }
 
 
@@ -174,7 +174,7 @@ Array<GenericEditor*> SplitterEditor::getConnectedEditors()
     Array<GenericEditor*> editors;
 
     Splitter* processor = (Splitter*) getProcessor();
-    
+
     for (int pathNum = 0; pathNum < 2; pathNum++)
     {
         processor->switchIO();
@@ -184,9 +184,9 @@ Array<GenericEditor*> SplitterEditor::getConnectedEditors()
         else
             editors.add(nullptr);
     }
-    
+
     return editors;
-    
+
 }
 
 void SplitterEditor::switchDest()
diff --git a/Source/Processors/Editors/SplitterEditor.h b/Source/Processors/Editors/SplitterEditor.h
index ddcd447616c9a6a21bb40cc9097beb31a20caff1..dcb8e789d31a5009ac2c7251c34c6c5828b838d9 100755
--- a/Source/Processors/Editors/SplitterEditor.h
+++ b/Source/Processors/Editors/SplitterEditor.h
@@ -48,7 +48,7 @@ public:
     void switchDest();
 
     void switchIO(int i);
-    
+
     int getPathForEditor(GenericEditor* editor);
     Array<GenericEditor*> getConnectedEditors();
 
diff --git a/Source/Processors/Editors/VisualizerEditor.cpp b/Source/Processors/Editors/VisualizerEditor.cpp
index ba71a50dde567cb45b4541bc4e36d85b99f23212..820cd074a1cdf181160872bb54304f294c243836 100755
--- a/Source/Processors/Editors/VisualizerEditor.cpp
+++ b/Source/Processors/Editors/VisualizerEditor.cpp
@@ -305,13 +305,13 @@ void VisualizerEditor::loadCustomParameters(XmlElement* xml)
             if (windowState)
             {
                 windowSelector->setToggleState(true, sendNotification);
-				if (dataWindow != nullptr)
-				{
-					dataWindow->setBounds(xmlNode->getIntAttribute("x"),
-						                  xmlNode->getIntAttribute("y"),
-							              xmlNode->getIntAttribute("width"),
-								          xmlNode->getIntAttribute("height"));
-				}
+                if (dataWindow != nullptr)
+                {
+                    dataWindow->setBounds(xmlNode->getIntAttribute("x"),
+                                          xmlNode->getIntAttribute("y"),
+                                          xmlNode->getIntAttribute("width"),
+                                          xmlNode->getIntAttribute("height"));
+                }
 
             }
 
diff --git a/Source/Processors/FileReader.cpp b/Source/Processors/FileReader.cpp
index d38b56bd7c949d195ae38cfe4d3984d75df8e927..b4c239f9b70163c23684173e2bdc6d794ef88259 100644
--- a/Source/Processors/FileReader.cpp
+++ b/Source/Processors/FileReader.cpp
@@ -162,7 +162,7 @@ void FileReader::process(AudioSampleBuffer& buffer, MidiBuffer& events, int& nSa
     //     counter++;
 
     // }
-    
+
 
 
     int samplesNeeded = (int) float(buffer.getNumSamples()) * (getDefaultSampleRate()/44100.0f);
@@ -200,9 +200,9 @@ void FileReader::process(AudioSampleBuffer& buffer, MidiBuffer& events, int& nSa
         int16 sample = readBuffer[n];
 
 #ifdef JUCE_WINDOWS //-- big-endian format
-            // reverse the byte order
-	//	float sample_f;
-	//	AudioDataConverters::convertInt16BEToFloat(&readBuffer[n], &sample_f, 1);
+        // reverse the byte order
+        //	float sample_f;
+        //	AudioDataConverters::convertInt16BEToFloat(&readBuffer[n], &sample_f, 1);
 
 #endif
 
diff --git a/Source/Processors/FilterNode.cpp b/Source/Processors/FilterNode.cpp
index 9a9f8e6eaacf2c26e5db76e5447d4a901516f0fc..9c38eb22fa8080f921bf9af659897e57c9692455 100755
--- a/Source/Processors/FilterNode.cpp
+++ b/Source/Processors/FilterNode.cpp
@@ -46,7 +46,7 @@ FilterNode::FilterNode()
     // highCutValues.add(9000.0f);
 
     // parameters.add(Parameter("high cut",highCutValues, 2, 1));
-	applyOnADC = false;
+    applyOnADC = false;
 }
 
 FilterNode::~FilterNode()
@@ -126,15 +126,15 @@ AudioProcessorEditor* FilterNode::createEditor()
 
 void FilterNode::updateSettings()
 {
-	int id = nodeId;
-	int numInputs = getNumInputs();
-	int numfilt = filters.size();
+    int id = nodeId;
+    int numInputs = getNumInputs();
+    int numfilt = filters.size();
     if (numInputs < 1024 && numInputs != numfilt)
     {
-		// SO fixed this. I think values were never restored correctly because you cleared lowCuts.
-	    Array<double> oldlowCuts, oldhighCuts;
-		oldlowCuts = lowCuts;
-		oldhighCuts = highCuts;
+        // SO fixed this. I think values were never restored correctly because you cleared lowCuts.
+        Array<double> oldlowCuts, oldhighCuts;
+        oldlowCuts = lowCuts;
+        oldhighCuts = highCuts;
 
         filters.clear();
         lowCuts.clear();
@@ -169,7 +169,9 @@ void FilterNode::updateSettings()
             {
                 lc = oldlowCuts[n];
                 hc = oldhighCuts[n];
-            } else {
+            }
+            else
+            {
                 lc = defaultLowCut;
                 hc = defaultHighCut;
             }
@@ -228,7 +230,7 @@ void FilterNode::setParameter(int parameterIndex, float newValue)
 
         if (parameterIndex == 0)
         {
-           // std::cout << " low cut to " << newValue << std::endl;
+            // std::cout << " low cut to " << newValue << std::endl;
             lowCuts.set(currentChannel,newValue);
         }
         else if (parameterIndex == 1)
@@ -237,21 +239,24 @@ void FilterNode::setParameter(int parameterIndex, float newValue)
             highCuts.set(currentChannel,newValue);
         }
 
-          setFilterParameters(lowCuts[currentChannel],
-                        highCuts[currentChannel],
-                        currentChannel);
+        setFilterParameters(lowCuts[currentChannel],
+                            highCuts[currentChannel],
+                            currentChannel);
 
         editor->updateParameterButtons(parameterIndex);
 
-    } else // change channel bypass state
+    }
+    else   // change channel bypass state
     {
         if (newValue == 0)
         {
             shouldFilterChannel.set(currentChannel, false);
-        } else {
+        }
+        else
+        {
             shouldFilterChannel.set(currentChannel, true);
         }
-        
+
     }
 }
 
@@ -262,11 +267,11 @@ void FilterNode::process(AudioSampleBuffer& buffer,
 
     for (int n = 0; n < getNumOutputs(); n++)
     {
-		if (shouldFilterChannel[n])
-		{
-			float* ptr = buffer.getWritePointer(n);
-			filters[n]->process(nSamples, &ptr);
-		}
+        if (shouldFilterChannel[n])
+        {
+            float* ptr = buffer.getWritePointer(n);
+            filters[n]->process(nSamples, &ptr);
+        }
     }
 
 }
diff --git a/Source/Processors/FilterNode.h b/Source/Processors/FilterNode.h
index b5ea5f337df644410b623258331f74b1c7dc47cb..b07818fc78d851d3fd402e04e17a71f1ed55b658 100755
--- a/Source/Processors/FilterNode.h
+++ b/Source/Processors/FilterNode.h
@@ -65,15 +65,15 @@ public:
     void saveCustomChannelParametersToXml(XmlElement* channelInfo, int channelNumber, bool isEventChannel);
 
     void loadCustomChannelParametersFromXml(XmlElement* channelInfo, bool isEventChannel);
-	
-	void setApplyOnADC(bool state);
+
+    void setApplyOnADC(bool state);
 private:
 
     Array<double> lowCuts, highCuts;
     OwnedArray<Dsp::Filter> filters;
     Array<bool> shouldFilterChannel;
 
-	bool applyOnADC;
+    bool applyOnADC;
     double defaultLowCut;
     double defaultHighCut;
 
diff --git a/Source/Processors/GenericProcessor.cpp b/Source/Processors/GenericProcessor.cpp
index 584a7e7835031249d075d13e8438ee747578b4da..0a06d487a33828b09f086fda1bdc4026273987e7 100755
--- a/Source/Processors/GenericProcessor.cpp
+++ b/Source/Processors/GenericProcessor.cpp
@@ -27,9 +27,9 @@
 GenericProcessor::GenericProcessor(const String& name_) : AccessClass(),
     sourceNode(0), destNode(0), isEnabled(true), wasConnected(false),
     nextAvailableChannel(0), saveOrder(-1), loadOrder(-1), currentChannel(-1),
-     parametersAsXml(nullptr),  name(name_), paramsWereLoaded(false), editor(0), sendSampleCount(true)
+    parametersAsXml(nullptr),  name(name_), paramsWereLoaded(false), editor(0), sendSampleCount(true)
 {
-	  settings.numInputs = settings.numOutputs = settings.sampleRate = 0;
+    settings.numInputs = settings.numOutputs = settings.sampleRate = 0;
 
 }
 
@@ -277,14 +277,14 @@ void GenericProcessor::clearSettings()
     settings.numOutputs = 0;
     settings.sampleRate = getDefaultSampleRate();
 
-   // std::cout << "Record status size = " << recordStatus.size() << std::endl;
+    // std::cout << "Record status size = " << recordStatus.size() << std::endl;
 
     if (recordStatus.size() < channels.size())
         recordStatus.resize(channels.size());
 
     for (int i = 0; i < channels.size(); i++)
     {
-       // std::cout << channels[i]->getRecordState() << std::endl;
+        // std::cout << channels[i]->getRecordState() << std::endl;
         recordStatus.set(i,channels[i]->getRecordState());
     }
 
@@ -297,14 +297,14 @@ void GenericProcessor::update()
 {
 
     //std::cout << getName() << " updating settings." << std::endl;
-	// SO patched here to keep original channel names
+    // SO patched here to keep original channel names
 
-	int oldNumChannels = channels.size();
-	StringArray oldNames;
-	for (int k = 0; k < oldNumChannels; k++)
-	{
-		oldNames.add(channels[k]->getName());
-	}
+    int oldNumChannels = channels.size();
+    StringArray oldNames;
+    for (int k = 0; k < oldNumChannels; k++)
+    {
+        oldNames.add(channels[k]->getName());
+    }
 
     clearSettings();
 
@@ -344,33 +344,33 @@ void GenericProcessor::update()
     {
         settings.numOutputs = getDefaultNumOutputs();
         settings.sampleRate = getDefaultSampleRate();
-		
-		int numChan = getNumOutputs();
-		int numADC_Chan = getDefaultADCoutputs();
+
+        int numChan = getNumOutputs();
+        int numADC_Chan = getDefaultADCoutputs();
         for (int i = 0; i < numChan; i++)
         {
-            Channel* ch = new Channel(this, i );
+            Channel* ch = new Channel(this, i);
 
-			// if (i < oldNumChannels)
-			// 	ch->setName(oldNames[i]);
-			//else if (i >= numChan-numADC_Chan) 
-			//	ch->setName("ADC"+String(1+i-(numChan-numADC_Chan)));
+            // if (i < oldNumChannels)
+            // 	ch->setName(oldNames[i]);
+            //else if (i >= numChan-numADC_Chan)
+            //	ch->setName("ADC"+String(1+i-(numChan-numADC_Chan)));
 
-            if (i >= numChan-numADC_Chan) 
-              ch->setName("ADC"+String(1+i-(numChan-numADC_Chan)));
+            if (i >= numChan-numADC_Chan)
+                ch->setName("ADC"+String(1+i-(numChan-numADC_Chan)));
 
             if (i >= numChan-numADC_Chan)
-              ch->isADCchannel = true;
-            
+                ch->isADCchannel = true;
+
 
             ch->sampleRate = getDefaultSampleRate();
 
-          //  if (ch->isADCchannel)
-                ch->bitVolts = getDefaultBitVolts();
-          //  else
-          //      ch->bitVolts = getDefaultAdcBitVolts(); // should implement this
+            //  if (ch->isADCchannel)
+            ch->bitVolts = getDefaultBitVolts();
+            //  else
+            //      ch->bitVolts = getDefaultAdcBitVolts(); // should implement this
 
-             if (i < recordStatus.size())
+            if (i < recordStatus.size())
             {
                 ch->setRecordState(recordStatus[i]);
             }
@@ -408,7 +408,7 @@ void GenericProcessor::setAllChannelsToRecord()
         recordStatus.set(i,true);
     }
 
-   // std::cout << "Setting all channels to record for source." << std::endl;
+    // std::cout << "Setting all channels to record for source." << std::endl;
 
 }
 
@@ -453,13 +453,13 @@ int GenericProcessor::getNumSamples(MidiBuffer& events)
     //
     // This loops through all events in the buffer, and uses the BUFFER_SIZE
     // events to determine the number of samples in the current buffer. If
-    // there are multiple such events, the one with the highest number of 
+    // there are multiple such events, the one with the highest number of
     // samples will be used.
     // This approach is not ideal, as it will become a problem if we allow
     // the sample rate to change at different points in the signal chain.
     //
 
-    int numRead = 0; 
+    int numRead = 0;
 
     //int numRead = 0;
 
@@ -479,25 +479,26 @@ int GenericProcessor::getNumSamples(MidiBuffer& events)
         while (i.getNextEvent(dataptr, dataSize, samplePosition))
         {
 
-             if (*dataptr == BUFFER_SIZE)
-             {
-                
+            if (*dataptr == BUFFER_SIZE)
+            {
+
                 int16 nr;
                 memcpy(&nr, dataptr+2, 2);
 
-                 numRead = nr;
-
-             } else 
+                numRead = nr;
 
-            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
-            {
-                // 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
             }
+            else
+
+                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
+                {
+                    // 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
+                }
         }
     }
 
@@ -510,11 +511,11 @@ void GenericProcessor::setNumSamples(MidiBuffer& events, int sampleIndex)
     // This amounts to adding a "buffer size" flag at a particular sample number,
     // and a new flag is added each time "setNumSamples" is called.
     // Thus, if the number of samples changes somewhere in the processing pipeline,
-    // the old sample number will remain. This is a problem if the number of 
+    // the old sample number will remain. This is a problem if the number of
     // samples gets smaller.
     // If we allow the sample rate to change (e.g., with a resampling node),
     // this code will have to be updated. The easiest approach will be for each
-    // processor to ignore any buffer size events that don't come from its 
+    // processor to ignore any buffer size events that don't come from its
     // immediate source.
     //
 
@@ -530,7 +531,7 @@ void GenericProcessor::setNumSamples(MidiBuffer& events, int sampleIndex)
                     4,          // total bytes
                     0); // sample index
 
-   // std::cout << "Processor " << getNodeId() << " adding a new sample count of " << sampleIndex << std::endl;
+    // std::cout << "Processor " << getNodeId() << " adding a new sample count of " << sampleIndex << std::endl;
 
 }
 
@@ -601,7 +602,7 @@ void GenericProcessor::processBlock(AudioSampleBuffer& buffer, MidiBuffer& event
 {
 
     int nSamples = getNumSamples(eventBuffer); // finds buffer size and sets save
-                                               // flag on all TTL events to zero
+    // flag on all TTL events to zero
 
     process(buffer, eventBuffer, nSamples);
 
@@ -724,7 +725,7 @@ void GenericProcessor::loadFromXml()
 
     update(); // make sure settings are updated
 
-  
+
     if (!paramsWereLoaded)
     {
 
diff --git a/Source/Processors/GenericProcessor.h b/Source/Processors/GenericProcessor.h
index 3323b8bd032793dda19b20e2ffc779546a3f8870..ec3fe318a7be013fbd5a7580e376723e5cf3d6a9 100755
--- a/Source/Processors/GenericProcessor.h
+++ b/Source/Processors/GenericProcessor.h
@@ -277,7 +277,7 @@ public:
         return 2;
     }
 
-	  virtual int getDefaultADCoutputs()
+    virtual int getDefaultADCoutputs()
     {
         return 0;
     }
@@ -365,7 +365,7 @@ public:
     {
         return false;
     }
-    
+
     /** Returns true if a processor is a utility (non-merger or splitter), false otherwise.*/
     virtual bool isUtility()
     {
@@ -404,7 +404,7 @@ public:
     
     /** Called from setRecording whenever recording has started. */
     virtual void startRecording() { }
-    
+
     /** Called from setrecording whenever recording has stopped. */
     virtual void stopRecording() { }
 
@@ -478,8 +478,8 @@ public:
         SPIKE = 4,
         EEG = 5,
         CONTINUOUS = 6,
-		NETWORK = 7,
-		EYE_POSITION = 8,
+        NETWORK = 7,
+        EYE_POSITION = 8,
         SERIAL = 9
     };
 
@@ -587,8 +587,11 @@ public:
     /** Load custom parameters for each channel. */
     virtual void loadCustomChannelParametersFromXml(XmlElement* channelElement, bool isEventChannel=false);
 
-	/** handle messages from other processors */
-	virtual String interProcessorCommunication(String command) { return String("OK"); };
+    /** handle messages from other processors */
+    virtual String interProcessorCommunication(String command)
+    {
+        return String("OK");
+    };
 
     /** Holds loaded parameters */
     XmlElement* parametersAsXml;
diff --git a/Source/Processors/LfpDisplayNode.cpp b/Source/Processors/LfpDisplayNode.cpp
index cac9272fcde90d0dd1b6588acfffb8cb02347aff..577e140c05a190a1ebf6b3c965c05e716ff08f7e 100755
--- a/Source/Processors/LfpDisplayNode.cpp
+++ b/Source/Processors/LfpDisplayNode.cpp
@@ -58,7 +58,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;
 }
 
 bool LfpDisplayNode::resizeBuffer()
diff --git a/Source/Processors/PhaseDetector.cpp b/Source/Processors/PhaseDetector.cpp
index cbe11531827c0db3fdbd9cda2806f80eff72010b..0a6d07df0749c013b21b62073549df5b47a5bb2d 100644
--- a/Source/Processors/PhaseDetector.cpp
+++ b/Source/Processors/PhaseDetector.cpp
@@ -28,7 +28,7 @@
 PhaseDetector::PhaseDetector()
     : GenericProcessor("Phase Detector"), activeModule(-1),
       risingPos(false), risingNeg(false), fallingPos(false), fallingNeg(false)
-      
+
 {
 
 }
@@ -72,7 +72,7 @@ void PhaseDetector::setActiveModule(int i)
 
 void PhaseDetector::setParameter(int parameterIndex, float newValue)
 {
-    
+
     DetectorModule& module = modules.getReference(activeModule);
 
     if (parameterIndex == 1) // module type
@@ -100,19 +100,24 @@ void PhaseDetector::setParameter(int parameterIndex, float newValue)
             default:
                 module.type = NONE;
         }
-    } else if (parameterIndex == 2) // inputChan
+    }
+    else if (parameterIndex == 2)   // inputChan
     {
         module.inputChan = (int) newValue;
-    } else if (parameterIndex == 3) // outputChan
+    }
+    else if (parameterIndex == 3)   // outputChan
     {
         module.outputChan = (int) newValue;
-    } else if (parameterIndex == 4) // gateChan
+    }
+    else if (parameterIndex == 4)   // gateChan
     {
         module.gateChan = (int) newValue;
         if (module.gateChan < 0)
         {
             module.isActive = true;
-        } else {
+        }
+        else
+        {
             module.isActive = false;
         }
     }
@@ -154,7 +159,7 @@ void PhaseDetector::handleEvent(int eventType, MidiMessage& event, int sampleNum
                     module.isActive = true;
                 else
                     module.isActive = false;
-            } 
+            }
         }
 
     }
@@ -175,7 +180,7 @@ void PhaseDetector::process(AudioSampleBuffer& buffer,
 
         // check to see if it's active and has a channel
         if (module.isActive && module.outputChan >= 0 &&
-            module.inputChan >= 0 && 
+            module.inputChan >= 0 &&
             module.inputChan < buffer.getNumChannels())
         {
 
@@ -195,7 +200,8 @@ void PhaseDetector::process(AudioSampleBuffer& buffer,
 
                     module.phase = FALLING_POS;
 
-                } else if (sample < 0 && module.lastSample >= 0 && module.phase != FALLING_NEG)
+                }
+                else if (sample < 0 && module.lastSample >= 0 && module.phase != FALLING_NEG)
                 {
 
                     if (module.type == FALLING_ZERO)
@@ -205,9 +211,10 @@ void PhaseDetector::process(AudioSampleBuffer& buffer,
                         module.wasTriggered = true;
                     }
 
-                     module.phase = FALLING_NEG;
+                    module.phase = FALLING_NEG;
 
-                } else if (sample > module.lastSample && sample < 0 && module.phase != RISING_NEG)
+                }
+                else if (sample > module.lastSample && sample < 0 && module.phase != RISING_NEG)
                 {
 
                     if (module.type == TROUGH)
@@ -219,7 +226,8 @@ void PhaseDetector::process(AudioSampleBuffer& buffer,
 
                     module.phase = RISING_NEG;
 
-                } else if (sample > 0 && module.lastSample <= 0 && module.phase != RISING_POS)
+                }
+                else if (sample > 0 && module.lastSample <= 0 && module.phase != RISING_POS)
                 {
 
                     if (module.type == RISING_ZERO)
@@ -250,7 +258,7 @@ void PhaseDetector::process(AudioSampleBuffer& buffer,
 
             }
 
-            
+
         }
 
     }
diff --git a/Source/Processors/PhaseDetector.h b/Source/Processors/PhaseDetector.h
index eccdb897673c6a18ea3205768741118677b04c84..21dddad125b7ddb3d83b7c6c29affeae39f545b0 100644
--- a/Source/Processors/PhaseDetector.h
+++ b/Source/Processors/PhaseDetector.h
@@ -65,15 +65,18 @@ public:
 
 private:
 
-    enum ModuleType {
-        NONE, PEAK, FALLING_ZERO, TROUGH, RISING_ZERO 
+    enum ModuleType
+    {
+        NONE, PEAK, FALLING_ZERO, TROUGH, RISING_ZERO
     };
 
-    enum PhaseType {
+    enum PhaseType
+    {
         NO_PHASE, RISING_POS, FALLING_POS, FALLING_NEG, RISING_NEG
     };
 
-    struct DetectorModule {
+    struct DetectorModule
+    {
 
         int inputChan;
         int gateChan;
diff --git a/Source/Processors/ProcessorGraph.cpp b/Source/Processors/ProcessorGraph.cpp
index 7a12a51af8cddc9affc5610e357fc774970d8545..b8064be2a9c620c08d719f1941e88f1f90480cb7 100644
--- a/Source/Processors/ProcessorGraph.cpp
+++ b/Source/Processors/ProcessorGraph.cpp
@@ -67,9 +67,9 @@ ProcessorGraph::ProcessorGraph() : currentNodeId(100)
 
 }
 
-ProcessorGraph::~ProcessorGraph() 
+ProcessorGraph::~ProcessorGraph()
 {
-	
+
 }
 
 void ProcessorGraph::createDefaultNodes()
@@ -112,7 +112,7 @@ void* ProcessorGraph::createNewProcessor(String& description, int id)//,
 
     GenericProcessor* processor = createProcessorFromDescription(description);
 
-   // int id = currentNodeId++;
+    // int id = currentNodeId++;
 
     if (processor != 0)
     {
@@ -152,7 +152,7 @@ void ProcessorGraph::clearSignalChain()
 
     for (int i = 0; i < processors.size(); i++)
     {
-         removeProcessor(processors[i]);
+        removeProcessor(processors[i]);
     }
 
 }
@@ -211,7 +211,7 @@ Array<GenericProcessor*> ProcessorGraph::getListOfProcessors()
 
     Array<GenericProcessor*> a;
 
-     for (int i = 0; i < getNumNodes(); i++)
+    for (int i = 0; i < getNumNodes(); i++)
     {
         Node* node = getNode(i);
 
@@ -247,7 +247,7 @@ void ProcessorGraph::clearConnections()
             {
                 disconnectNode(node->nodeId);
             }
-            
+
             GenericProcessor* p = (GenericProcessor*) node->getProcessor();
             p->resetConnections();
 
@@ -277,7 +277,7 @@ void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSect
 
     std::cout << "Updating connections:" << std::endl;
     std::cout << std::endl;
-     std::cout << std::endl;
+    std::cout << std::endl;
 
     Array<GenericProcessor*> splitters;
     // GenericProcessor* activeSplitter = nullptr;
@@ -298,15 +298,17 @@ void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSect
             if (source->enabledState())
             {
                 // add the connections to audio and record nodes if necessary
-                if (!(source->isSink()     || 
-                      source->isSplitter() || 
-                      source->isMerger()   || 
-                      source->isUtility()) 
+                if (!(source->isSink()     ||
+                      source->isSplitter() ||
+                      source->isMerger()   ||
+                      source->isUtility())
                     && !(source->wasConnected))
                 {
                     std::cout << "     Connecting to audio and record nodes." << std::endl;
                     connectProcessorToAudioAndRecordNodes(source);
-                } else {
+                }
+                else
+                {
                     std::cout << "     NOT connecting to audio and record nodes." << std::endl;
                 }
 
@@ -331,7 +333,9 @@ void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSect
                                 {
                                     splitters.add(dest);
                                     dest->switchIO(0); // go down first path
-                                } else {
+                                }
+                                else
+                                {
                                     int splitterIndex = splitters.indexOf(dest);
                                     splitters.remove(splitterIndex);
                                     dest->switchIO(1); // go down second path
@@ -350,15 +354,19 @@ void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSect
 
                             if (dest->enabledState())
                             {
-                               connectProcessors(source, dest);
+                                connectProcessors(source, dest);
                             }
                         }
 
-                    } else {
+                    }
+                    else
+                    {
                         std::cout << "     No dest node." << std::endl;
                     }
 
-                } else {
+                }
+                else
+                {
                     std::cout << "     No dest node." << std::endl;
                 }
             }
@@ -380,7 +388,7 @@ void ProcessorGraph::updateConnections(Array<SignalChainTabButton*, CriticalSect
                     newSource->setPathToProcessor(source);
                     source = newSource;
                 }
-                
+
             }
 
         } // end while source != 0
@@ -434,7 +442,7 @@ void ProcessorGraph::connectProcessorToAudioAndRecordNodes(GenericProcessor* sou
 
         // THIS IS A HACK TO MAKE SURE AUDIO NODE KNOWS WHAT THE SAMPLE RATE SHOULD BE
         // IT CAN CAUSE PROBLEMS IF THE SAMPLE RATE VARIES ACROSS PROCESSORS
-        getAudioNode()->settings.sampleRate = source->getSampleRate(); 
+        getAudioNode()->settings.sampleRate = source->getSampleRate();
 
         addConnection(source->getNodeId(),                   // sourceNodeID
                       chan,                                  // sourceNodeChannelIndex
@@ -511,7 +519,7 @@ GenericProcessor* ProcessorGraph::createProcessorFromDescription(String& descrip
         {
             processor = new FileReader();
             std::cout << "Creating a new file reader." << std::endl;
-        }   
+        }
         else if (subProcessorType.equalsIgnoreCase("Serial Port"))
         {
             processor = new SerialInput();
@@ -553,7 +561,7 @@ GenericProcessor* ProcessorGraph::createProcessorFromDescription(String& descrip
         {
             std::cout << "Creating a new channel mapping node." << std::endl;
             processor = new ChannelMappingNode();
-        } 
+        }
 
         sendActionMessage("New filter node created.");
 
@@ -603,8 +611,8 @@ GenericProcessor* ProcessorGraph::createProcessorFromDescription(String& descrip
         {
             std::cout << "Creating a SpikeDisplayNode." << std::endl;
             processor = new SpikeDisplayNode();
-        } 
-    
+        }
+
         else if (subProcessorType.equalsIgnoreCase("WiFi Output"))
         {
             std::cout << "Creating a WiFi node." << std::endl;
@@ -753,23 +761,25 @@ void ProcessorGraph::setRecordState(bool isRecording)
     if (isRecording)
     {
         getRecordNode()->setParameter(1,10.0f);
-    } else {
+    }
+    else
+    {
         getRecordNode()->setParameter(0,10.0f);
     }
-    
+
     for (int i = 0; i < getNumNodes(); i++)
     {
         Node* node = getNode(i);
         if (node->nodeId != OUTPUT_NODE_ID)
         {
             GenericProcessor* p = (GenericProcessor*) node->getProcessor();
-            
+
 			p->setRecording(isRecording);
         }
     }
-    
-    
-    
+
+
+
 }
 
 
diff --git a/Source/Processors/ProcessorGraph.h b/Source/Processors/ProcessorGraph.h
index e8a4b04d4c3cd8fd51eff9c42188bedb95a5a918..48919679b6b86a3644f6d5b55a66709aa110b764 100644
--- a/Source/Processors/ProcessorGraph.h
+++ b/Source/Processors/ProcessorGraph.h
@@ -61,7 +61,7 @@ public:
     GenericProcessor* createProcessorFromDescription(String& description);
 
     void removeProcessor(GenericProcessor* processor);
-	Array<GenericProcessor*> getListOfProcessors();
+    Array<GenericProcessor*> getListOfProcessors();
     void clearSignalChain();
 
     bool enableProcessors();
@@ -80,7 +80,7 @@ public:
     void restoreParameters();
 
     void updatePointers();
-    
+
     void setRecordState(bool);
 
     void refreshColors();
diff --git a/Source/Processors/RecordNode.cpp b/Source/Processors/RecordNode.cpp
index 2f60bb8dba8eb2ac60d02b036b9e1fe71bb81e28..deed5fd1fccee08cdff18dc1bffe15a60c4c7295 100755
--- a/Source/Processors/RecordNode.cpp
+++ b/Source/Processors/RecordNode.cpp
@@ -178,6 +178,7 @@ void RecordNode::createNewDirectory()
     rootFolder = File(dataDirectory.getFullPathName() + File::separator + generateDirectoryName());
     newDirectoryNeeded = false;
 
+
 }
 
 String RecordNode::generateDirectoryName()
diff --git a/Source/Processors/RecordNode.h b/Source/Processors/RecordNode.h
index 0764963ddb74c172a3353a090c0c2a3977f4edc6..6787b0d221176aa4999e7927f341d596a3891c87 100755
--- a/Source/Processors/RecordNode.h
+++ b/Source/Processors/RecordNode.h
@@ -107,6 +107,7 @@ public:
     */
     void createNewDirectory();
 
+
     File getDataDirectory()
     {
         return rootFolder;
@@ -131,6 +132,11 @@ public:
     /** Generate a Matlab-compatible datestring */
     String generateDateString();
 
+    CriticalSection* getLock()
+    {
+        return &diskWriteLock;
+    }
+
 private:
 
     /** Keep the RecordNode informed of acquisition and record states.
diff --git a/Source/Processors/Serial/PulsePal.cpp b/Source/Processors/Serial/PulsePal.cpp
index 1918fb87f45cae90f465cfcaf5f7c351c2115248..8dccb1fbb41558a669f5e9f4e242dd1362953048 100644
--- a/Source/Processors/Serial/PulsePal.cpp
+++ b/Source/Processors/Serial/PulsePal.cpp
@@ -37,7 +37,7 @@
 PulsePal::PulsePal()
 {
     setDefaultParameters();
-        
+
 }
 
 PulsePal::~PulsePal()
@@ -87,16 +87,16 @@ void PulsePal::initialize()
 
     vector<ofSerialDeviceInfo> devices = serial.getDeviceList();
 
-   // bool foundDevice = false;
-	if (devices.size() == 0)
-	{
-		std::cout << "No serial devices found!" << std::endl;
-		return;
-	}
+    // bool foundDevice = false;
+    if (devices.size() == 0)
+    {
+        std::cout << "No serial devices found!" << std::endl;
+        return;
+    }
 
     int id = devices[0].getDeviceID();
-        string path = devices[0].getDevicePath();
-        string name = devices[0].getDeviceName();
+    string path = devices[0].getDevicePath();
+    string name = devices[0].getDeviceName();
 
     serial.setup(id, 115200);
     std::cout << "Found!" << std::endl;
@@ -108,12 +108,12 @@ uint32_t PulsePal::getFirmwareVersion() // JS 1/30/2014
     uint8_t handshakeByte = 72;
     uint8_t responseBytes[5] = { 0 };
     serial.writeByte(handshakeByte);
-	#if defined( TARGET_OSX ) || defined( TARGET_LINUX )
-  usleep(100000);
+#if defined( TARGET_OSX ) || defined( TARGET_LINUX )
+    usleep(100000);
 #else
-	Sleep(100);
+    Sleep(100);
 #endif
-  
+
     serial.readBytes(responseBytes,5);
     firmwareVersion = makeLong(responseBytes[4], responseBytes[3], responseBytes[2], responseBytes[1]);
     return firmwareVersion;
@@ -373,12 +373,14 @@ uint8_t PulsePal::voltageToByte(float voltage)
 
 }
 
-void PulsePal::programCustomTrain(uint8_t ID, uint8_t nPulses, float customPulseTimes[], float customVoltages[]){
+void PulsePal::programCustomTrain(uint8_t ID, uint8_t nPulses, float customPulseTimes[], float customVoltages[])
+{
     int nMessageBytes = (nPulses * 5) + 6;
     // Convert voltages to bytes
     uint8_t voltageBytes[1000] = { 0 };
     float thisVoltage = 0;
-    for (int i = 0; i < nPulses; i++) {
+    for (int i = 0; i < nPulses; i++)
+    {
         thisVoltage = customVoltages[i];
         voltageBytes[i] = voltageToByte(thisVoltage);
     }
@@ -386,18 +388,25 @@ void PulsePal::programCustomTrain(uint8_t ID, uint8_t nPulses, float customPulse
     uint8_t pulseTimeBytes[4000] = { 0 };
     int pos = 0;
     unsigned long pulseTimeMicroseconds;
-    for (int i = 0; i < nPulses; i++){
+    for (int i = 0; i < nPulses; i++)
+    {
         pulseTimeMicroseconds = (unsigned long)(customPulseTimes[i] * 1000000);
-        pulseTimeBytes[pos] = (uint8_t)(pulseTimeMicroseconds); pos++;
-        pulseTimeBytes[pos] = (uint8_t)(pulseTimeMicroseconds >> 8); pos++;
-        pulseTimeBytes[pos] = (uint8_t)(pulseTimeMicroseconds >> 16); pos++;
-        pulseTimeBytes[pos] = (uint8_t)(pulseTimeMicroseconds >> 24); pos++;
+        pulseTimeBytes[pos] = (uint8_t)(pulseTimeMicroseconds);
+        pos++;
+        pulseTimeBytes[pos] = (uint8_t)(pulseTimeMicroseconds >> 8);
+        pos++;
+        pulseTimeBytes[pos] = (uint8_t)(pulseTimeMicroseconds >> 16);
+        pos++;
+        pulseTimeBytes[pos] = (uint8_t)(pulseTimeMicroseconds >> 24);
+        pos++;
     }
-    uint8_t *messageBytes = new uint8_t[nMessageBytes];
-    if (ID == 2) {
+    uint8_t* messageBytes = new uint8_t[nMessageBytes];
+    if (ID == 2)
+    {
         messageBytes[0] = 76; // Op code to program custom train 2
     }
-    else {
+    else
+    {
         messageBytes[0] = 75; // Op code to program custom train 1
     }
     messageBytes[1] = 0; // USB packet correction byte
@@ -406,16 +415,19 @@ void PulsePal::programCustomTrain(uint8_t ID, uint8_t nPulses, float customPulse
     messageBytes[4] = (uint8_t)(nPulses >> 16);
     messageBytes[5] = (uint8_t)(nPulses >> 24);
     int timeDataEnd = 6 + (nPulses * 4);
-    for (int i = 6; i < timeDataEnd; i++){
+    for (int i = 6; i < timeDataEnd; i++)
+    {
         messageBytes[i] = pulseTimeBytes[i - 6];
     }
-    for (int i = timeDataEnd; i < nMessageBytes; i++){
+    for (int i = timeDataEnd; i < nMessageBytes; i++)
+    {
         messageBytes[i] = voltageBytes[i - timeDataEnd];
     }
     serial.writeBytes(messageBytes, nMessageBytes);
 }
 
-void PulsePal::programAllParams() {
+void PulsePal::programAllParams()
+{
     uint8_t messageBytes[163] = { 0 };
     messageBytes[0] = 73;
     int pos = 1;
@@ -424,75 +436,121 @@ void PulsePal::programAllParams() {
     uint8_t thisVoltageByte = 0;
 
     // add time params
-    for (int i = 1; i < 5; i++){
+    for (int i = 1; i < 5; i++)
+    {
         thisTime = (uint32_t)(currentOutputParams[i].phase1Duration * 1000000);
-        messageBytes[pos] = (uint8_t)(thisTime); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 8); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 16); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 24); pos++;
+        messageBytes[pos] = (uint8_t)(thisTime);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 8);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 16);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 24);
+        pos++;
         thisTime = (uint32_t)(currentOutputParams[i].interPhaseInterval * 1000000);
-        messageBytes[pos] = (uint8_t)(thisTime); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 8); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 16); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 24); pos++;
+        messageBytes[pos] = (uint8_t)(thisTime);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 8);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 16);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 24);
+        pos++;
         thisTime = (uint32_t)(currentOutputParams[i].phase2Duration * 1000000);
-        messageBytes[pos] = (uint8_t)(thisTime); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 8); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 16); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 24); pos++;
+        messageBytes[pos] = (uint8_t)(thisTime);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 8);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 16);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 24);
+        pos++;
         thisTime = (uint32_t)(currentOutputParams[i].interPulseInterval * 1000000);
-        messageBytes[pos] = (uint8_t)(thisTime); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 8); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 16); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 24); pos++;
+        messageBytes[pos] = (uint8_t)(thisTime);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 8);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 16);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 24);
+        pos++;
         thisTime = (uint32_t)(currentOutputParams[i].burstDuration * 1000000);
-        messageBytes[pos] = (uint8_t)(thisTime); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 8); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 16); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 24); pos++;
+        messageBytes[pos] = (uint8_t)(thisTime);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 8);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 16);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 24);
+        pos++;
         thisTime = (uint32_t)(currentOutputParams[i].interBurstInterval * 1000000);
-        messageBytes[pos] = (uint8_t)(thisTime); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 8); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 16); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 24); pos++;
+        messageBytes[pos] = (uint8_t)(thisTime);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 8);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 16);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 24);
+        pos++;
         thisTime = (uint32_t)(currentOutputParams[i].pulseTrainDuration * 1000000);
-        messageBytes[pos] = (uint8_t)(thisTime); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 8); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 16); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 24); pos++;
+        messageBytes[pos] = (uint8_t)(thisTime);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 8);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 16);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 24);
+        pos++;
         thisTime = (uint32_t)(currentOutputParams[i].pulseTrainDelay * 1000000);
-        messageBytes[pos] = (uint8_t)(thisTime); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 8); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 16); pos++;
-        messageBytes[pos] = (uint8_t)(thisTime >> 24); pos++;
+        messageBytes[pos] = (uint8_t)(thisTime);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 8);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 16);
+        pos++;
+        messageBytes[pos] = (uint8_t)(thisTime >> 24);
+        pos++;
     }
 
     // add single-byte params
-    for (int i = 1; i < 5; i++){
-        messageBytes[pos] = (uint8_t)currentOutputParams[i].isBiphasic; pos++;
+    for (int i = 1; i < 5; i++)
+    {
+        messageBytes[pos] = (uint8_t)currentOutputParams[i].isBiphasic;
+        pos++;
         thisVoltage = PulsePal::currentOutputParams[i].phase1Voltage;
         thisVoltageByte = voltageToByte(thisVoltage);
-        messageBytes[pos] = thisVoltageByte; pos++;
+        messageBytes[pos] = thisVoltageByte;
+        pos++;
         thisVoltage = PulsePal::currentOutputParams[i].phase2Voltage;
         thisVoltageByte = voltageToByte(thisVoltage);
-        messageBytes[pos] = thisVoltageByte; pos++;
-        messageBytes[pos] = (uint8_t)currentOutputParams[i].customTrainID; pos++;
-        messageBytes[pos] = (uint8_t)currentOutputParams[i].customTrainTarget; pos++;
-        messageBytes[pos] = (uint8_t)currentOutputParams[i].customTrainLoop; pos++;
+        messageBytes[pos] = thisVoltageByte;
+        pos++;
+        messageBytes[pos] = (uint8_t)currentOutputParams[i].customTrainID;
+        pos++;
+        messageBytes[pos] = (uint8_t)currentOutputParams[i].customTrainTarget;
+        pos++;
+        messageBytes[pos] = (uint8_t)currentOutputParams[i].customTrainLoop;
+        pos++;
     }
 
     // add trigger channel 1 links
-    for (int i = 1; i < 5; i++){
-        messageBytes[pos] = (uint8_t)currentOutputParams[i].linkTriggerChannel1; pos++; 
+    for (int i = 1; i < 5; i++)
+    {
+        messageBytes[pos] = (uint8_t)currentOutputParams[i].linkTriggerChannel1;
+        pos++;
     }
     // add trigger channel 2 links
-    for (int i = 1; i < 5; i++){
-        messageBytes[pos] = (uint8_t)currentOutputParams[i].linkTriggerChannel2; pos++;
+    for (int i = 1; i < 5; i++)
+    {
+        messageBytes[pos] = (uint8_t)currentOutputParams[i].linkTriggerChannel2;
+        pos++;
     }
 
     // add trigger channel modes
-        messageBytes[pos] = (uint8_t)currentInputParams[1].triggerMode; pos++;
-        messageBytes[pos] = (uint8_t)currentInputParams[2].triggerMode; pos++;
+    messageBytes[pos] = (uint8_t)currentInputParams[1].triggerMode;
+    pos++;
+    messageBytes[pos] = (uint8_t)currentInputParams[2].triggerMode;
+    pos++;
 
 
     serial.writeBytes(messageBytes, 163);
diff --git a/Source/Processors/Serial/PulsePal.h b/Source/Processors/Serial/PulsePal.h
index ec307ac7211ea1ff5648a990a3150580eb8677b4..819f2c4d59a957e2135d72e5858a2052e7d2e8d7 100644
--- a/Source/Processors/Serial/PulsePal.h
+++ b/Source/Processors/Serial/PulsePal.h
@@ -31,7 +31,7 @@
 #include "ofSerial.h"
 
 /**
-  Interface to PulsePal 
+  Interface to PulsePal
   @see PulsePalOutput
 
 */
@@ -81,9 +81,10 @@ public:
     void abortPulseTrains();
     void setContinuousLoop(uint8_t channel, uint8_t state);
     void setTriggerMode(uint8_t channel, uint8_t mode);
-    
+
     // Fields
-    struct OutputParams {
+    struct OutputParams
+    {
         int isBiphasic;
         float phase1Voltage;
         float phase2Voltage;
@@ -101,7 +102,8 @@ public:
         int customTrainTarget;
         int customTrainLoop;
     } currentOutputParams[5]; // Use 1-indexing for the channels (output channels 1-4 = currentOutputParams[1]-currentOutputParams[4])
-    struct InputParams {
+    struct InputParams
+    {
         int triggerMode;
     } currentInputParams[3]; // Use 1-indexing for the trigger channels
 
diff --git a/Source/Processors/SerialInput.cpp b/Source/Processors/SerialInput.cpp
index f8aa468dcc6fdcbc349f691c1d11cd24365a26f3..4946179ffb22247f8ea5cb1eddb8223d7b7bc52d 100644
--- a/Source/Processors/SerialInput.cpp
+++ b/Source/Processors/SerialInput.cpp
@@ -1,24 +1,24 @@
 /*
  ------------------------------------------------------------------
- 
+
  This file is part of the Open Ephys GUI
  Copyright (C) 2013 Florian Franzen
- 
+
  ------------------------------------------------------------------
- 
+
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
- 
+
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
- 
+
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- 
+
  */
 
 
@@ -37,16 +37,17 @@ SerialInput::~SerialInput()
     serial.close();
 }
 
-StringArray SerialInput::getDevices() {
+StringArray SerialInput::getDevices()
+{
     vector<ofSerialDeviceInfo> allDeviceInfos = serial.getDeviceList();
-    
+
     StringArray allDevices;
-    
-    for(int i = 0; i < allDeviceInfos.size(); i++)
+
+    for (int i = 0; i < allDeviceInfos.size(); i++)
     {
         allDevices.add(allDeviceInfos[i].getDeviceName());
     }
-    
+
     return allDevices;
 }
 
@@ -69,12 +70,12 @@ void SerialInput::setBaudrate(int baudrate)
 
 bool SerialInput::isReady()
 {
-    if(device == "" || baudrate == 0)
+    if (device == "" || baudrate == 0)
     {
         AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "SerialInput connection error!", "Please set device and baudrate to use first!");
         return false;
     }
-    if(!serial.setup(device, baudrate))
+    if (!serial.setup(device, baudrate))
     {
         AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "SerialInput connection error!", "Could not connect to specified serial device. Check log files for details.");
         return false;
@@ -92,19 +93,20 @@ bool SerialInput::disable()
 void SerialInput::process(AudioSampleBuffer&, MidiBuffer& events, int&)
 {
     int bytesAvailable = serial.available();
-    
+
     if (bytesAvailable == OF_SERIAL_ERROR)
     {
         // ToDo: Properly warn about problem here!
         AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "SerialInput device access error!", "Could not access serial device.");
         return;
     }
-    
-    if (bytesAvailable > 0){
+
+    if (bytesAvailable > 0)
+    {
 
         unsigned char buffer[10000];
         int bytesRead = serial.readBytes(buffer, bytesAvailable);
-        
+
         if (bytesRead > 0)
         {
             addEvent(events,    // MidiBuffer
@@ -124,7 +126,8 @@ void SerialInput::process(AudioSampleBuffer&, MidiBuffer& events, int&)
     }
 }
 
-AudioProcessorEditor* SerialInput::createEditor() {
+AudioProcessorEditor* SerialInput::createEditor()
+{
     editor = new SerialInputEditor(this);
     return editor;
 }
diff --git a/Source/Processors/SerialInput.h b/Source/Processors/SerialInput.h
index 9aee1baec754ec7c77e1dc1d2eb1542474595b5d..44b14d36595071478cb76b17542813d5448d2157 100644
--- a/Source/Processors/SerialInput.h
+++ b/Source/Processors/SerialInput.h
@@ -1,24 +1,24 @@
 /*
  ------------------------------------------------------------------
- 
+
  This file is part of the Open Ephys GUI
  Copyright (C) 2013 Florian Franzen
- 
+
  ------------------------------------------------------------------
- 
+
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
- 
+
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
- 
+
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- 
+
  */
 
 #ifndef __SERIALINPUT_H_B8E3F86B__
@@ -35,37 +35,37 @@
 #include "Serial/ofSerial.h"
 
 /**
- 
+
  This source processor allows you to pipe binary serial data input straight to the event cue/buffer.
- 
+
  @see SerialInputEditor
- 
+
  */
 
 class SerialInput : public GenericProcessor
 
 {
 public:
-    
+
     /** The class constructor, used to initialize any members. */
     SerialInput();
-    
+
     /** The class destructor, used to deallocate memory */
     virtual ~SerialInput();
-    
+
     /**
      Returns a list of all serial devices that are available on the system.
-     
+
      The list of available devices changes whenever devices are connected or removed.
      */
     StringArray getDevices();
-    
-    /** 
+
+    /**
      Returns a list of all supported baudrates.
      */
     Array<int> getBaudrates();
-    
-    /** 
+
+    /**
      Used by the ProcessorGraph to determines whether the processor should be treated as a source.
 
      Returns always true, since SerialInput is a source.
@@ -74,56 +74,56 @@ public:
     {
         return true;
     }
-    
-    /** 
+
+    /**
      This should only be run by the ProcessorGraph, before acquisition will be started.
-     
+
      It tries to open the serial port previsouly specified by the setDevice and setBaudrate setters.
-     
+
      Returns true on success, false if port could not be opened.
      */
     bool isReady();
-    
-    /** 
+
+    /**
      Called immediately after the end of data acquisition by the ProcessorGraph.
-     
+
      It closes the open port serial port.
      */
     bool disable();
-    
+
     /** Setter, that allows you to set the serial device that will be used during acquisition */
     void setDevice(string device);
-    
+
     /** Setter, that allows you to set the baudrate that will be used during acquisition */
     void setBaudrate(int baudrate);
 
     /** Defines the functionality of the processor.
-     
+
      The process method is called every time a new data buffer is available.
-     
+
      Adds all the new serial data that is available to the event data buffer.
      */
     void process(AudioSampleBuffer& buffer, MidiBuffer& events, int& nSamples);
-    
+
     /**
      Returns the Juce GUI component that should be used with this processor.
      */
     AudioProcessorEditor* createEditor();
-    
+
 private:
-    
+
     // The current serial connection
     ofSerial serial;
-    
+
     // The serial device to be used
     string device;
-    
+
     // The baudrate to be used
     int baudrate;
 
     // List of baudrates that are available by default.
     static const int BAUDRATES[12];
-    
+
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SerialInput);
 };
 
diff --git a/Source/Processors/SourceNode.cpp b/Source/Processors/SourceNode.cpp
index e5b689213194c12340360260b178811e85831e74..b93733cc3ac78235606544384d0e3b661639224f 100755
--- a/Source/Processors/SourceNode.cpp
+++ b/Source/Processors/SourceNode.cpp
@@ -43,7 +43,7 @@ SourceNode::SourceNode(const String& name_)
 
     if (getName().equalsIgnoreCase("RHA2000-EVAL"))
     {
-       // dataThread = new IntanThread(this);
+        // dataThread = new IntanThread(this);
     }
     else if (getName().equalsIgnoreCase("Custom FPGA"))
     {
@@ -417,7 +417,7 @@ void SourceNode::saveCustomParametersToXml(XmlElement* parentElement)
         FileReaderThread* thread = (FileReaderThread*) dataThread.get();
         childNode->setAttribute("path", thread->getFile());
 
-    } 
+    }
 
 }
 
@@ -436,7 +436,7 @@ void SourceNode::loadCustomParametersFromXml()
                 FileReaderEditor* fre = (FileReaderEditor*) getEditor();
                 fre->setFile(filepath);
 
-            } 
+            }
         }
     }
 
diff --git a/Source/Processors/SpikeDetector.cpp b/Source/Processors/SpikeDetector.cpp
index 6aa269fab5599eb4b7f30bd26704ed6b8c654302..534a84734f123d51ddaa8b982365542c9e85952f 100755
--- a/Source/Processors/SpikeDetector.cpp
+++ b/Source/Processors/SpikeDetector.cpp
@@ -243,7 +243,7 @@ Electrode* SpikeDetector::setCurrentElectrodeIndex(int i)
 Electrode* SpikeDetector::getActiveElectrode()
 {
     if (electrodes.size() == 0)
-      return nullptr;
+        return nullptr;
 
     return electrodes[currentElectrode];
 }
@@ -332,7 +332,7 @@ void SpikeDetector::addSpikeEvent(SpikeObject* s, MidiBuffer& eventBuffer, int p
 
     if (numBytes > 0)
         eventBuffer.addEvent(spikeBuffer, numBytes, peakIndex);
-    
+
     //std::cout << "Adding spike" << std::endl;
 }
 
@@ -359,7 +359,7 @@ void SpikeDetector::addWaveformToSpikeObject(SpikeObject* s,
     {
 
         for (int sample = 0; sample < spikeLength; sample++)
-        { 
+        {
 
             // warning -- be careful of bitvolts conversion
             s->data[currentIndex] = uint16(getNextSample(*(electrodes[electrodeNumber]->channels+currentChannel)) / channels[chan]->bitVolts + 32768);
@@ -493,8 +493,8 @@ void SpikeDetector::process(AudioSampleBuffer& buffer,
 
                         }
 
-                       //for (int xxx = 0; xxx < 1000; xxx++) // overload with spikes for testing purposes
-                            addSpikeEvent(&newSpike, events, peakIndex);
+                        //for (int xxx = 0; xxx < 1000; xxx++) // overload with spikes for testing purposes
+                        addSpikeEvent(&newSpike, events, peakIndex);
 
                         // advance the sample index
                         sampleIndex = peakIndex + electrode->postPeakSamples;
@@ -651,7 +651,7 @@ void SpikeDetector::saveCustomParametersToXml(XmlElement* parentElement)
 void SpikeDetector::loadCustomParametersFromXml()
 {
 
-   
+
     if (parametersAsXml != nullptr) // prevent double-loading
     {
         // use parametersAsXml to restore state
@@ -690,7 +690,7 @@ void SpikeDetector::loadCustomParametersFromXml()
                         setChannelThreshold(electrodeIndex, channelIndex, channelNode->getDoubleAttribute("thresh"));
                         setChannelActive(electrodeIndex, channelIndex, channelNode->getBoolAttribute("isActive"));
                     }
-               }
+                }
 
 
             }
diff --git a/Source/Processors/SpikeDisplayNode.cpp b/Source/Processors/SpikeDisplayNode.cpp
index 06ab7d5b201b6abdeac390b3b986a41ce5b0c4ad..6de204f29a1f19fdd831b20a323727375b141d5a 100755
--- a/Source/Processors/SpikeDisplayNode.cpp
+++ b/Source/Processors/SpikeDisplayNode.cpp
@@ -34,11 +34,12 @@ SpikeDisplayNode::SpikeDisplayNode()
 	isRecording(false)
 {
 
+
 }
 
 SpikeDisplayNode::~SpikeDisplayNode()
 {
-    
+
 }
 
 AudioProcessorEditor* SpikeDisplayNode::createEditor()
@@ -118,7 +119,9 @@ int SpikeDisplayNode::getNumberOfChannelsForElectrode(int i)
     if (i > -1 && i < electrodes.size())
     {
         return electrodes[i].numChannels;
-    } else {
+    }
+    else
+    {
         return 0;
     }
 }
@@ -129,7 +132,9 @@ String SpikeDisplayNode::getNameForElectrode(int i)
     if (i > -1 && i < electrodes.size())
     {
         return electrodes[i].name;
-    } else {
+    }
+    else
+    {
         return " ";
     }
 }
@@ -158,7 +163,7 @@ int SpikeDisplayNode::getNumElectrodes()
 
 void SpikeDisplayNode::startRecording()
 {
-    
+
     setParameter(1, 0.0f); // need to use the 'setParameter' method to interact with 'process'
 }
 
@@ -176,11 +181,13 @@ void SpikeDisplayNode::setParameter(int param, float val)
     {
         isRecording = false;
 
-    } else if (param == 1) // start recording
+    }
+    else if (param == 1)   // start recording
     {
         isRecording = true;
 
-    } else if (param == 2) // redraw
+    }
+    else if (param == 2)   // redraw
     {
         redrawRequested = true;
 
@@ -206,8 +213,8 @@ void SpikeDisplayNode::process(AudioSampleBuffer& buffer, MidiBuffer& events, in
             // update thresholds
             for (int j = 0; j < e.numChannels; j++)
             {
-                e.displayThresholds.set(j, 
-                e.spikePlot->getDisplayThresholdForChannel(j));
+                e.displayThresholds.set(j,
+                                        e.spikePlot->getDisplayThresholdForChannel(j));
 
                 e.spikePlot->setDetectorThresholdForChannel(j, e.detectorThresholds[j]);
             }
@@ -237,7 +244,7 @@ void SpikeDisplayNode::handleEvent(int eventType, MidiMessage& event, int sample
 
         const uint8_t* dataptr = event.getRawData();
         int bufferSize = event.getRawDataSize();
-            
+
         if (bufferSize > 0)
         {
 
@@ -250,16 +257,16 @@ void SpikeDisplayNode::handleEvent(int eventType, MidiMessage& event, int sample
                 int electrodeNum = newSpike.source;
 
                 Electrode& e = electrodes.getReference(electrodeNum);
-               // std::cout << electrodeNum << std::endl;
+                // std::cout << electrodeNum << std::endl;
 
-                 bool aboveThreshold = false;
+                bool aboveThreshold = false;
 
                 // update threshold / check threshold
                 for (int i = 0; i < e.numChannels; i++)
                 {
                     e.detectorThresholds.set(i, float(newSpike.threshold[i])); // / float(newSpike.gain[i]));
 
-                    aboveThreshold = aboveThreshold | checkThreshold(i, e.displayThresholds[i], newSpike);   
+                    aboveThreshold = aboveThreshold | checkThreshold(i, e.displayThresholds[i], newSpike);
                 }
 
                 if (aboveThreshold)
@@ -268,11 +275,11 @@ void SpikeDisplayNode::handleEvent(int eventType, MidiMessage& event, int sample
                     // add to buffer
                     if (e.currentSpikeIndex < displayBufferSize)
                     {
-                      //  std::cout << "Adding spike " << e.currentSpikeIndex + 1 << std::endl;
+                        //  std::cout << "Adding spike " << e.currentSpikeIndex + 1 << std::endl;
                         e.mostRecentSpikes.set(e.currentSpikeIndex, newSpike);
                         e.currentSpikeIndex++;
                     }
-                    
+
                     // save spike
                     if (isRecording)
                     {
@@ -281,7 +288,7 @@ void SpikeDisplayNode::handleEvent(int eventType, MidiMessage& event, int sample
                 }
 
             }
-        
+
         }
 
     }
diff --git a/Source/Processors/SpikeDisplayNode.h b/Source/Processors/SpikeDisplayNode.h
index 3fa0c364b97b33a31d1efa93a750b3379a8e285d..159dc69fddd75c33a280b7b2333f187743a49ce1 100755
--- a/Source/Processors/SpikeDisplayNode.h
+++ b/Source/Processors/SpikeDisplayNode.h
@@ -66,7 +66,7 @@ public:
 
     bool enable();
     bool disable();
-    
+
     void startRecording();
     void stopRecording();
 
@@ -114,7 +114,7 @@ private:
  //   SpikeObject currentSpike;
 
  //   uint16 recordingNumber;
-    
+
 //    CriticalSection* diskWriteLock;
 
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SpikeDisplayNode);
diff --git a/Source/Processors/Utilities/Merger.cpp b/Source/Processors/Utilities/Merger.cpp
index 2bf958eceb2290a93ac323e13c8b8cab56a12a3f..fa88ecc55ad88a503fdbcfabd699109389193783 100755
--- a/Source/Processors/Utilities/Merger.cpp
+++ b/Source/Processors/Utilities/Merger.cpp
@@ -89,7 +89,7 @@ void Merger::switchIO(int sourceNum)
         //std::cout << "Source node: " << getSourceNode() << std::endl;
     }
 
-   // getEditorViewport()->makeEditorVisible((GenericEditor*) getEditor(), false);
+    // getEditorViewport()->makeEditorVisible((GenericEditor*) getEditor(), false);
 
 }
 
@@ -199,55 +199,55 @@ void Merger::updateSettings()
 void Merger::saveCustomParametersToXml(XmlElement* parentElement)
 {
     XmlElement* mainNode = parentElement->createNewChildElement("MERGER");
-	if (sourceNodeA!= nullptr)
-		mainNode->setAttribute("NodeA",	sourceNodeA->getNodeId());
-	else
-		mainNode->setAttribute("NodeA",	-1);
-
-	if (sourceNodeB != nullptr)
-		mainNode->setAttribute("NodeB",	sourceNodeB->getNodeId());
-	else
-		mainNode->setAttribute("NodeB",	-1);
+    if (sourceNodeA!= nullptr)
+        mainNode->setAttribute("NodeA",	sourceNodeA->getNodeId());
+    else
+        mainNode->setAttribute("NodeA",	-1);
+
+    if (sourceNodeB != nullptr)
+        mainNode->setAttribute("NodeB",	sourceNodeB->getNodeId());
+    else
+        mainNode->setAttribute("NodeB",	-1);
 }
 
 
 void Merger::loadCustomParametersFromXml()
 {
-	if (1)
-	{
-	if (parametersAsXml != nullptr)
-	{
-		forEachXmlChildElement(*parametersAsXml, mainNode)
-		{
-			if (mainNode->hasTagName("MERGER"))
-			{
-				int NodeAid = mainNode->getIntAttribute("NodeA");
-				int NodeBid = mainNode->getIntAttribute("NodeB");
-
-				ProcessorGraph *gr = getProcessorGraph();
-				Array<GenericProcessor*> p = gr->getListOfProcessors();
-				
-                for (int k = 0; k < p.size(); k++)
-				{
-					if (p[k]->getNodeId() == NodeAid)
-                    {
-                        std::cout << "Setting Merger source A to " << NodeAid << std::endl;
-                        switchIO(0);
-						setMergerSourceNode(p[k]);
-					}
-                    if (p[k]->getNodeId() == NodeBid)
+    if (1)
+    {
+        if (parametersAsXml != nullptr)
+        {
+            forEachXmlChildElement(*parametersAsXml, mainNode)
+            {
+                if (mainNode->hasTagName("MERGER"))
+                {
+                    int NodeAid = mainNode->getIntAttribute("NodeA");
+                    int NodeBid = mainNode->getIntAttribute("NodeB");
+
+                    ProcessorGraph* gr = getProcessorGraph();
+                    Array<GenericProcessor*> p = gr->getListOfProcessors();
+
+                    for (int k = 0; k < p.size(); k++)
                     {
-                        std::cout << "Setting Merger source B to " << NodeBid << std::endl;
-						switchIO(1);
-                        setMergerSourceNode(p[k]);
-				    }
+                        if (p[k]->getNodeId() == NodeAid)
+                        {
+                            std::cout << "Setting Merger source A to " << NodeAid << std::endl;
+                            switchIO(0);
+                            setMergerSourceNode(p[k]);
+                        }
+                        if (p[k]->getNodeId() == NodeBid)
+                        {
+                            std::cout << "Setting Merger source B to " << NodeBid << std::endl;
+                            switchIO(1);
+                            setMergerSourceNode(p[k]);
+                        }
+                    }
+
+                    updateSettings();
                 }
-				
-                updateSettings();
-			}
-		}
-	}
-}
+            }
+        }
+    }
 }
 
 // void Merger::setNumOutputs(int /*outputs*/)
diff --git a/Source/Processors/Utilities/Merger.h b/Source/Processors/Utilities/Merger.h
index 9f0ccd674aedea2782738b72122f243bc7d26c14..820684c1eed01f3e7aed0d4101e91871b7d3d25e 100755
--- a/Source/Processors/Utilities/Merger.h
+++ b/Source/Processors/Utilities/Merger.h
@@ -67,9 +67,9 @@ public:
     void addSettingsFromSourceNode(GenericProcessor* sn);
 
     bool stillHasSource();
-	
-	void saveCustomParametersToXml(XmlElement* parentElement);
-	void loadCustomParametersFromXml();
+
+    void saveCustomParametersToXml(XmlElement* parentElement);
+    void loadCustomParametersFromXml();
 
 private:
 
diff --git a/Source/Processors/Utilities/RecordControl.cpp b/Source/Processors/Utilities/RecordControl.cpp
index 3c2858611c2f621cb1e336ad0cc8c2de69a95ded..fac0f4022a5df57324409d52f9fa03d0838aafe7 100644
--- a/Source/Processors/Utilities/RecordControl.cpp
+++ b/Source/Processors/Utilities/RecordControl.cpp
@@ -27,7 +27,7 @@
 #include "../../UI/ControlPanel.h"
 
 RecordControl::RecordControl()
-    : GenericProcessor("Record Control"), 
+    : GenericProcessor("Record Control"),
       createNewFilesOnTrigger(false), triggerChannel(0), recordNode(0)
 {
 
@@ -49,14 +49,18 @@ void RecordControl::setParameter(int parameterIndex, float newValue)
     if (parameterIndex == 0)
     {
         updateTriggerChannel((int) newValue);
-    } else {
-        
+    }
+    else
+    {
+
         if (newValue == 0.0)
         {
             createNewFilesOnTrigger = false;
-            
-            
-        } else {
+
+
+        }
+        else
+        {
             createNewFilesOnTrigger = true;
         }
         //recordNode->appendTrialNumber(createNewFilesOnTrigger);
@@ -72,9 +76,9 @@ bool RecordControl::enable()
 {
     if (recordNode == 0)
         recordNode = getProcessorGraph()->getRecordNode();
-    
+
     //recordNode->appendTrialNumber(createNewFilesOnTrigger);
-    
+
     return true;
 }
 
diff --git a/Source/Processors/Utilities/RecordControl.h b/Source/Processors/Utilities/RecordControl.h
index 56c47bc6004e039ef8a120d21e4194105964a6f9..594c8d04acb2eb421c592da49f0278de3f89d072 100644
--- a/Source/Processors/Utilities/RecordControl.h
+++ b/Source/Processors/Utilities/RecordControl.h
@@ -48,17 +48,20 @@ public:
     void updateTriggerChannel(int newChannel);
     void handleEvent(int eventType, MidiMessage& event, int);
     bool enable();
-    
+
     bool createNewFilesOnTrigger;
-    
-    bool isUtility() {return true;}
+
+    bool isUtility()
+    {
+        return true;
+    }
 
     AudioProcessorEditor* createEditor();
 
 private:
     int triggerChannel;
-    
-    
+
+
     RecordNode* recordNode;
 
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(RecordControl);
diff --git a/Source/Processors/Utilities/Splitter.cpp b/Source/Processors/Utilities/Splitter.cpp
index 1105d3251222d0f30cf5f0d5b0a92b9e40749321..94da0a3565f82ff38e092a32e7cf5aea586c788e 100755
--- a/Source/Processors/Utilities/Splitter.cpp
+++ b/Source/Processors/Utilities/Splitter.cpp
@@ -90,15 +90,15 @@ void Splitter::switchIO(int destNum)
     if (destNum == 0)
     {
         destNode = destNodeA;
-       // std::cout << "Dest node: " << getDestNode() << std::endl;
+        // std::cout << "Dest node: " << getDestNode() << std::endl;
     }
     else
     {
         destNode = destNodeB;
-       // std::cout << "Dest node: " << getDestNode() << std::endl;
+        // std::cout << "Dest node: " << getDestNode() << std::endl;
     }
 
-   // getEditorViewport()->makeEditorVisible(getEditor(), false);
+    // getEditorViewport()->makeEditorVisible(getEditor(), false);
 
 }
 
diff --git a/Source/Processors/Visualization/DataWindow.cpp b/Source/Processors/Visualization/DataWindow.cpp
index d26ff88553585258a2a9871e6fe4d62bda06d7d5..e147e090f90198c597df43ab55fb42c701a66c38 100755
--- a/Source/Processors/Visualization/DataWindow.cpp
+++ b/Source/Processors/Visualization/DataWindow.cpp
@@ -44,7 +44,7 @@ DataWindow::~DataWindow()
 
 void DataWindow::closeButtonPressed()
 {
-	setContentNonOwned(0,false);
+    setContentNonOwned(0,false);
     setVisible(false);
     controlButton->setToggleState(false,dontSendNotification);
-}
\ No newline at end of file
+}
diff --git a/Source/Processors/Visualization/LfpDisplayCanvas.cpp b/Source/Processors/Visualization/LfpDisplayCanvas.cpp
index f6c005a14b1377537945b19957f4ec9ddd358e18..722babcec417c143c7f4a00a700038e93b473acd 100755
--- a/Source/Processors/Visualization/LfpDisplayCanvas.cpp
+++ b/Source/Processors/Visualization/LfpDisplayCanvas.cpp
@@ -1,23 +1,23 @@
 /*
-    ------------------------------------------------------------------
+------------------------------------------------------------------
 
-    This file is part of the Open Ephys GUI
-    Copyright (C) 2013 Open Ephys
+This file is part of the Open Ephys GUI
+Copyright (C) 2013 Open Ephys
 
-    ------------------------------------------------------------------
+------------------------------------------------------------------
 
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
@@ -26,455 +26,584 @@
 #include <math.h>
 
 LfpDisplayCanvas::LfpDisplayCanvas(LfpDisplayNode* processor_) :
-    screenBufferIndex(0), timebase(1.0f), displayGain(1.0f),   timeOffset(0.0f),
-    processor(processor_),
-    displayBufferIndex(0)
+	screenBufferIndex(0), timebase(1.0f), displayGain(1.0f),   timeOffset(0.0f),
+	processor(processor_),
+	displayBufferIndex(0)
 {
 
-    nChans = processor->getNumInputs();
-    sampleRate = processor->getSampleRate();
-    std::cout << "Setting num inputs on LfpDisplayCanvas to " << nChans << std::endl;
-
-    displayBuffer = processor->getDisplayBufferAddress();
-    displayBufferSize = displayBuffer->getNumSamples();
-    std::cout << "Setting displayBufferSize on LfpDisplayCanvas to " << displayBufferSize << std::endl;
-
-    screenBuffer = new AudioSampleBuffer(MAX_N_CHAN, MAX_N_SAMP);
-    screenBuffer->clear();
-
-    viewport = new Viewport();
-    lfpDisplay = new LfpDisplay(this, viewport);
-    timescale = new LfpTimescale(this);
-
-    timescale->setTimebase(timebase);
-
-    viewport->setViewedComponent(lfpDisplay, false);
-    viewport->setScrollBarsShown(true, false);
-
-    scrollBarThickness = viewport->getScrollBarThickness();
-
-    isChannelEnabled.insertMultiple(0,true,10000); // max 10k channels
-
-    //viewport->getVerticalScrollBar()->addListener(this->scrollBarMoved(viewport->getVerticalScrollBar(), 1.0));
-
-
-
-    addAndMakeVisible(viewport);
-    addAndMakeVisible(timescale);
-
-    voltageRanges.add("50");
-    voltageRanges.add("100");
-    voltageRanges.add("250");
-    voltageRanges.add("500");
-    voltageRanges.add("1000");
-    voltageRanges.add("2000");
-    voltageRanges.add("5000");
-
-    timebases.add("1.0");
-    timebases.add("2.0");
-    timebases.add("5.0");
-    timebases.add("10.0");
-
-    spreads.add("10");
-    spreads.add("20");
-    spreads.add("30");
-    spreads.add("40");
-    spreads.add("50");
-    spreads.add("60");
-
-    colorGroupings.add("1");
-    colorGroupings.add("2");
-    colorGroupings.add("4");
-    colorGroupings.add("8");
-    colorGroupings.add("16");
-
-
-    rangeSelection = new ComboBox("Voltage range");
-    rangeSelection->addItemList(voltageRanges, 1);
-    rangeSelection->setSelectedId(4, sendNotification);
-    rangeSelection->addListener(this);
-    addAndMakeVisible(rangeSelection);
-
-    timebaseSelection = new ComboBox("Timebase");
-    timebaseSelection->addItemList(timebases, 1);
-    timebaseSelection->setSelectedId(2, sendNotification);
-    timebaseSelection->addListener(this);
-    addAndMakeVisible(timebaseSelection);
-
-
-    spreadSelection = new ComboBox("Spread");
-    spreadSelection->addItemList(spreads, 1);
-    spreadSelection->setSelectedId(5,sendNotification);
-    spreadSelection->addListener(this);
-    addAndMakeVisible(spreadSelection);
-
-    colorGroupingSelection = new ComboBox("Color Grouping");
-    colorGroupingSelection->addItemList(colorGroupings, 1);
-    colorGroupingSelection->setSelectedId(1,sendNotification);
-    colorGroupingSelection->addListener(this);
-    addAndMakeVisible(colorGroupingSelection);
-
-    invertInputButton = new UtilityButton("Invert", Font("Small Text", 13, Font::plain));
-    invertInputButton->setRadius(5.0f);
-    invertInputButton->setEnabledState(true);
-    invertInputButton->setCorners(true, true, true, true);
-    invertInputButton->addListener(this);
-    invertInputButton->setClickingTogglesState(true);
-    invertInputButton->setToggleState(false, sendNotification);
-    addAndMakeVisible(invertInputButton);
-
-
-    lfpDisplay->setNumChannels(nChans);
-    lfpDisplay->setRange(1000.0f);
-
-    // add event display-specific controls (currently just an enable/disable button)
-    for (int i = 0; i < 8; i++)
-    {
+	nChans = processor->getNumInputs();
+	sampleRate = processor->getSampleRate();
+	std::cout << "Setting num inputs on LfpDisplayCanvas to " << nChans << std::endl;
 
+	displayBuffer = processor->getDisplayBufferAddress();
+	displayBufferSize = displayBuffer->getNumSamples();
+	std::cout << "Setting displayBufferSize on LfpDisplayCanvas to " << displayBufferSize << std::endl;
+
+	screenBuffer = new AudioSampleBuffer(MAX_N_CHAN, MAX_N_SAMP);
+	screenBuffer->clear();
+
+	screenBufferMin = new AudioSampleBuffer(MAX_N_CHAN, MAX_N_SAMP);
+	screenBufferMin->clear();
+	screenBufferMean = new AudioSampleBuffer(MAX_N_CHAN, MAX_N_SAMP);
+	screenBufferMean->clear();
+	screenBufferMax = new AudioSampleBuffer(MAX_N_CHAN, MAX_N_SAMP);
+	screenBufferMax->clear();
+
+	viewport = new Viewport();
+	lfpDisplay = new LfpDisplay(this, viewport);
+	timescale = new LfpTimescale(this);
+
+	timescale->setTimebase(timebase);
+
+	viewport->setViewedComponent(lfpDisplay, false);
+	viewport->setScrollBarsShown(true, false);
+
+	scrollBarThickness = viewport->getScrollBarThickness();
+
+	isChannelEnabled.insertMultiple(0,true,10000); // max 10k channels
+
+	//viewport->getVerticalScrollBar()->addListener(this->scrollBarMoved(viewport->getVerticalScrollBar(), 1.0));
+
+
+
+	addAndMakeVisible(viewport);
+	addAndMakeVisible(timescale);
+
+	voltageRanges.add("-"); // placeholder for custom ranges (set by scroll wheel etc.)
+	voltageRanges.add("50");
+	voltageRanges.add("100");
+	voltageRanges.add("250");
+	voltageRanges.add("500");
+	voltageRanges.add("1000");
+	voltageRanges.add("2000");
+	voltageRanges.add("5000");
+
+	timebases.add("1.0");
+	timebases.add("2.0");
+	timebases.add("5.0");
+	timebases.add("10.0");
+
+	spreads.add("-"); // placeholder for custom ranges (set by scroll wheel etc.)
+	spreads.add("10");
+	spreads.add("20");
+	spreads.add("30");
+	spreads.add("40");
+	spreads.add("50");
+	spreads.add("60");
+
+	colorGroupings.add("1");
+	colorGroupings.add("2");
+	colorGroupings.add("4");
+	colorGroupings.add("8");
+	colorGroupings.add("16");
+
+
+	rangeSelection = new ComboBox("Voltage range");
+	rangeSelection->addItemList(voltageRanges, 1);
+	rangeSelection->setSelectedId(5, sendNotification);
+	rangeSelection->addListener(this);
+	rangeSelection->setItemEnabled(1,false); //  '-' option not enabled- use this for manually selected ranges later
+	addAndMakeVisible(rangeSelection);
+
+
+	timebaseSelection = new ComboBox("Timebase");
+	timebaseSelection->addItemList(timebases, 1);
+	timebaseSelection->setSelectedId(2, sendNotification);
+	timebaseSelection->addListener(this);
+	addAndMakeVisible(timebaseSelection);
+
+
+	spreadSelection = new ComboBox("Spread");
+	spreadSelection->addItemList(spreads, 1);
+	spreadSelection->setSelectedId(6,sendNotification);
+	spreadSelection->addListener(this);
+	spreadSelection->setItemEnabled(1,false); //  '-' option not enabled- use this for manually selected ranges later
+	addAndMakeVisible(spreadSelection);
+
+	colorGroupingSelection = new ComboBox("Color Grouping");
+	colorGroupingSelection->addItemList(colorGroupings, 1);
+	colorGroupingSelection->setSelectedId(1,sendNotification);
+	colorGroupingSelection->addListener(this);
+	addAndMakeVisible(colorGroupingSelection);
+
+	invertInputButton = new UtilityButton("Invert", Font("Small Text", 13, Font::plain));
+	invertInputButton->setRadius(5.0f);
+	invertInputButton->setEnabledState(true);
+	invertInputButton->setCorners(true, true, true, true);
+	invertInputButton->addListener(this);
+	invertInputButton->setClickingTogglesState(true);
+	invertInputButton->setToggleState(false, sendNotification);
+	addAndMakeVisible(invertInputButton);
+
+	//button for controlling drawing algorithm - old line-style or new per-pixel style
+	drawMethodButton = new UtilityButton("DrawMethod", Font("Small Text", 13, Font::plain));
+	drawMethodButton->setRadius(5.0f);
+	drawMethodButton->setEnabledState(true);
+	drawMethodButton->setCorners(true, true, true, true);
+	drawMethodButton->addListener(this);
+	drawMethodButton->setClickingTogglesState(true);
+	drawMethodButton->setToggleState(false, sendNotification);
+	addAndMakeVisible(drawMethodButton);
+
+	//button for pausing the diaplsy - works by skipping buffer updates. This way scrolling etc still works
+	pauseButton = new UtilityButton("Pause", Font("Small Text", 13, Font::plain));
+	pauseButton->setRadius(5.0f);
+	pauseButton->setEnabledState(true);
+	pauseButton->setCorners(true, true, true, true);
+	pauseButton->addListener(this);
+	pauseButton->setClickingTogglesState(true);
+	pauseButton->setToggleState(false, sendNotification);
+	addAndMakeVisible(pauseButton);
+
+
+	lfpDisplay->setNumChannels(nChans);
+	lfpDisplay->setRange(1000.0f);
+
+	// add event display-specific controls (currently just an enable/disable button)
+	for (int i = 0; i < 8; i++)
+	{
 
-        EventDisplayInterface* eventOptions = new EventDisplayInterface(lfpDisplay, this, i);
-        eventDisplayInterfaces.add(eventOptions);
-        addAndMakeVisible(eventOptions);
-        eventOptions->setBounds(500+(floor(i/2)*20), getHeight()-20-(i%2)*20, 40, 20);
 
-        lfpDisplay->setEventDisplayState(i,true);
+		EventDisplayInterface* eventOptions = new EventDisplayInterface(lfpDisplay, this, i);
+		eventDisplayInterfaces.add(eventOptions);
+		addAndMakeVisible(eventOptions);
+		eventOptions->setBounds(500+(floor(i/2)*20), getHeight()-20-(i%2)*20, 40, 20);
 
-    }
+		lfpDisplay->setEventDisplayState(i,true);
 
+	}
 
+	TopLevelWindow::getTopLevelWindow(0)->addKeyListener(this);
 }
 
 LfpDisplayCanvas::~LfpDisplayCanvas()
 {
 
-    deleteAndZero(screenBuffer);
+	deleteAndZero(screenBuffer);
+	deleteAndZero(screenBufferMin);
+	deleteAndZero(screenBufferMean);
+	deleteAndZero(screenBufferMax);
+
+	TopLevelWindow::getTopLevelWindow(0)->removeKeyListener(this);
 }
 
 void LfpDisplayCanvas::resized()
 {
 
-    timescale->setBounds(leftmargin,0,getWidth()-scrollBarThickness-leftmargin,30);
-    viewport->setBounds(0,30,getWidth(),getHeight()-90);
+	timescale->setBounds(leftmargin,0,getWidth()-scrollBarThickness-leftmargin,30);
+	viewport->setBounds(0,30,getWidth(),getHeight()-90);
 
-    lfpDisplay->setBounds(0,0,getWidth()-scrollBarThickness, getChannelHeight()*nChans);
+	if (lfpDisplay->getSingleChannelState())
+		lfpDisplay->setChannelHeight(viewport->getHeight(),false);
 
-    rangeSelection->setBounds(5,getHeight()-30,100,25);
-    timebaseSelection->setBounds(175,getHeight()-30,100,25);
-    spreadSelection->setBounds(345,getHeight()-30,100,25);
-    colorGroupingSelection->setBounds(620,getHeight()-30,100,25);
-    invertInputButton->setBounds(750,getHeight()-30,100,25);
+	lfpDisplay->setBounds(0,0,getWidth()-scrollBarThickness, lfpDisplay->getChannelHeight()*nChans);
+	
+	rangeSelection->setBounds(5,getHeight()-30,100,25);
+	timebaseSelection->setBounds(175,getHeight()-30,100,25);
+	spreadSelection->setBounds(345,getHeight()-30,100,25);
+	colorGroupingSelection->setBounds(620,getHeight()-30,100,25);
 
-    for (int i = 0; i < 8; i++)
-    {
-        eventDisplayInterfaces[i]->setBounds(500+(floor(i/2)*20), getHeight()-40+(i%2)*20, 40, 20); // arrange event channel buttons in two rows
-        eventDisplayInterfaces[i]->repaint();
-    }
+	invertInputButton->setBounds(750,getHeight()-50,100,22);
+	drawMethodButton->setBounds(750,getHeight()-25,100,22);
+	pauseButton->setBounds(880,getHeight()-50,50,44);
+
+	for (int i = 0; i < 8; i++)
+	{
+		eventDisplayInterfaces[i]->setBounds(500+(floor(i/2)*20), getHeight()-40+(i%2)*20, 40, 20); // arrange event channel buttons in two rows
+		eventDisplayInterfaces[i]->repaint();
+	}
 
 
-    // std::cout << "Canvas thinks LfpDisplay should be this high: "
-    //  << lfpDisplay->getTotalHeight() << std::endl;
+	// std::cout << "Canvas thinks LfpDisplay should be this high: "
+	//  << lfpDisplay->getTotalHeight() << std::endl;
 
 }
 
 void LfpDisplayCanvas::beginAnimation()
 {
-    std::cout << "Beginning animation." << std::endl;
+	std::cout << "Beginning animation." << std::endl;
 
-    displayBufferSize = displayBuffer->getNumSamples();
+	displayBufferSize = displayBuffer->getNumSamples();
 
-    screenBufferIndex = 0;
+	screenBufferIndex = 0;
 
-    startCallbacks();
+	startCallbacks();
 }
 
 void LfpDisplayCanvas::endAnimation()
 {
-    std::cout << "Ending animation." << std::endl;
+	std::cout << "Ending animation." << std::endl;
 
-    stopCallbacks();
+	stopCallbacks();
 }
 
 void LfpDisplayCanvas::update()
 {
-    nChans = jmax(processor->getNumInputs(),1);
-    sampleRate = processor->getSampleRate();
+	nChans = jmax(processor->getNumInputs(),1);
+	sampleRate = processor->getSampleRate();
 
-    std::cout << "Setting sample rate of LfpDisplayCanvas to " << sampleRate << std::endl;
+	std::cout << "Setting sample rate of LfpDisplayCanvas to " << sampleRate << std::endl;
 
-    if (nChans != lfpDisplay->getNumChannels())
-    {
-    	std::cout << "Setting num inputs on LfpDisplayCanvas to " << nChans << std::endl;
+	if (nChans != lfpDisplay->getNumChannels())
+	{
+		std::cout << "Setting num inputs on LfpDisplayCanvas to " << nChans << std::endl;
 
-    	refreshScreenBuffer();
+		refreshScreenBuffer();
 
-    	lfpDisplay->setNumChannels(nChans);
+		lfpDisplay->setNumChannels(nChans);
 
-   	 	// update channel names
-   	 	for (int i = 0; i < processor->getNumInputs(); i++)
-    	{
+		// update channel names
+		for (int i = 0; i < processor->getNumInputs(); i++)
+		{
 
-	        String chName = processor->channels[i]->getName();
+			String chName = processor->channels[i]->getName();
 
-	        //std::cout << chName << std::endl;
+			//std::cout << chName << std::endl;
 
-	        lfpDisplay->channelInfo[i]->setName(chName);
-	        lfpDisplay->enableChannel(isChannelEnabled[i], i);
+			lfpDisplay->channelInfo[i]->setName(chName);
+			lfpDisplay->enableChannel(isChannelEnabled[i], i);
 
-    	}
+		}
 
-    	lfpDisplay->setBounds(0,0,getWidth()-scrollBarThickness*2, lfpDisplay->getTotalHeight());
+		lfpDisplay->setBounds(0,0,getWidth()-scrollBarThickness*2, lfpDisplay->getTotalHeight());
 
-    	resized();
-    }
+		resized();
+	}
 
 }
 
 void LfpDisplayCanvas::buttonClicked(Button* b)
 {
-    if (b == invertInputButton)
-    {
-        lfpDisplay->setInputInverted(b->getToggleState());
-    }
+	if (b == invertInputButton)
+	{
+		lfpDisplay->setInputInverted(b->getToggleState());
+	}
+	if (b == drawMethodButton)
+	{
+		lfpDisplay->setDrawMethod(b->getToggleState());
+	}
+	if (b == pauseButton)
+	{
+		lfpDisplay->isPaused = b->getToggleState();
+	}
+
 }
 
+
 void LfpDisplayCanvas::comboBoxChanged(ComboBox* cb)
 {
 
-    if (cb == timebaseSelection)
-    {
-        timebase = timebases[cb->getSelectedId()-1].getFloatValue();
-    }
-    else if (cb == rangeSelection)
-    {
-        lfpDisplay->setRange(voltageRanges[cb->getSelectedId()-1].getFloatValue());
-        //std::cout << "Setting range to " << voltageRanges[cb->getSelectedId()-1].getFloatValue() << std::endl;
-    }
-    else if (cb == spreadSelection)
-    {
-        //spread = spreads[cb->getSelectedId()-1].getFloatValue();
-        lfpDisplay->setChannelHeight(spreads[cb->getSelectedId()-1].getIntValue());
-        //lfpDisplay->resized();
-        resized();
-        //std::cout << "Setting spread to " << spreads[cb->getSelectedId()-1].getFloatValue() << std::endl;
-    }
-    else if (cb == colorGroupingSelection)
-    {
-        // set color grouping hre
+	if (cb == timebaseSelection)
+	{
+		timebase = timebases[cb->getSelectedId()-1].getFloatValue();
+	}
+	else if (cb == rangeSelection)
+	{
+		lfpDisplay->setRange(voltageRanges[cb->getSelectedId()-1].getFloatValue());
+		//std::cout << "Setting range to " << voltageRanges[cb->getSelectedId()-1].getFloatValue() << std::endl;
+	}
+	else if (cb == spreadSelection)
+	{
+		//spread = spreads[cb->getSelectedId()-1].getFloatValue();
+		lfpDisplay->setChannelHeight(spreads[cb->getSelectedId()-1].getIntValue());
+		resized();
+		
+		//std::cout << "Setting spread to " << spreads[cb->getSelectedId()-1].getFloatValue() << std::endl;
+	}
+	else if (cb == colorGroupingSelection)
+	{
+		// set color grouping hre
 
-        lfpDisplay->setColorGrouping(colorGroupings[cb->getSelectedId()-1].getIntValue());// so that channel colors get re-assigned 
+		lfpDisplay->setColorGrouping(colorGroupings[cb->getSelectedId()-1].getIntValue());// so that channel colors get re-assigned
 
-    }
+	}
 
-    timescale->setTimebase(timebase);
+	timescale->setTimebase(timebase);
 }
 
 
 int LfpDisplayCanvas::getChannelHeight()
 {
-    return spreads[spreadSelection->getSelectedId()-1].getIntValue();
-
+	return spreads[spreadSelection->getSelectedId()-1].getIntValue();
 }
 
 
 void LfpDisplayCanvas::setParameter(int param, float val)
 {
-    // if (param == 0)
-    // {
-    //     timebase = val;
-    //     refreshScreenBuffer();
-    // }
-    // else
-    // {
-    //     displayGain = val; //* 0.0001f;
-    // }
+	// if (param == 0)
+	// {
+	//     timebase = val;
+	//     refreshScreenBuffer();
+	// }
+	// else
+	// {
+	//     displayGain = val; //* 0.0001f;
+	// }
 
-    // repaint();
+	// repaint();
 }
 
-void LfpDisplayCanvas::refreshState()
+void LfpDisplayCanvas:: setRangeSelection(float range)
 {
-    // called when the component's tab becomes visible again
-    displayBufferIndex = processor->getDisplayBufferIndex();
-    screenBufferIndex = 0;
+			//rangeSelection->setItemEnabled(0,true); //keep custom range unavailable for direct selection
+			rangeSelection->setSelectedId(1,true);  // but show it for display
+			rangeSelection->changeItemText(1,String(int(range))); // and set to correct number
 
+			repaint();
+			refresh();
+			
 }
 
-void LfpDisplayCanvas::refreshScreenBuffer()
+void LfpDisplayCanvas:: setSpreadSelection(int spread)
 {
+			spreadSelection->setSelectedId(1,true);
+			spreadSelection->changeItemText(1,String(int(spread))); // and set to correct number
 
-    screenBufferIndex = 0;
-
-    screenBuffer->clear();
-
-    // int w = lfpDisplay->getWidth();
-    // //std::cout << "Refreshing buffer size to " << w << "pixels." << std::endl;
-
-    // for (int i = 0; i < w; i++)
-    // {
-    //  float x = float(i);
-
-    //  for (int n = 0; n < nChans; n++)
-    //  {
-    //      waves[n][i*2] = x;
-    //      waves[n][i*2+1] = 0.5f; // line in center of display
-    //  }
-    // }
-
+			repaint();
+			refresh();
+			
 }
 
-void LfpDisplayCanvas::updateScreenBuffer()
+void LfpDisplayCanvas::refreshState()
 {
+	// called when the component's tab becomes visible again
+	displayBufferIndex = processor->getDisplayBufferIndex();
+	screenBufferIndex = 0;
 
+}
 
-    // copy new samples from the displayBuffer into the screenBuffer (waves)
-    int maxSamples = lfpDisplay->getWidth() - leftmargin;
-
-    if (screenBufferIndex >= maxSamples) // wrap around if we reached right edge before
-        screenBufferIndex = 0;
-
-    lastScreenBufferIndex = screenBufferIndex;
-
-    int index = processor->getDisplayBufferIndex();
-
-    int nSamples =  index - displayBufferIndex; // N new samples to be addeddisplayBufferIndex
-
-    if (nSamples < 0) // buffer has reset to 0
-    {
-        nSamples = (displayBufferSize - displayBufferIndex) + index;
-    }
-
-    float ratio = sampleRate * timebase / float(getWidth() - leftmargin - scrollBarThickness);
+void LfpDisplayCanvas::refreshScreenBuffer()
+{
 
-    // this number is crucial: converting from samples to values (in px) for the screen buffer
-    int valuesNeeded = (int) float(nSamples) / ratio;
+	screenBufferIndex = 0;
 
+	screenBuffer->clear();
+	screenBufferMin->clear();
+	screenBufferMean->clear();
+	screenBufferMax->clear();
 
-    if (screenBufferIndex + valuesNeeded > maxSamples)  // crop number of samples to fit cavas width
-    {
-        valuesNeeded = maxSamples - screenBufferIndex;
-    }
 
-    float subSampleOffset = 0.0;
+	// int w = lfpDisplay->getWidth();
+	// //std::cout << "Refreshing buffer size to " << w << "pixels." << std::endl;
 
-    displayBufferIndex = displayBufferIndex % displayBufferSize; // make sure we're not overshooting
-    int nextPos = (displayBufferIndex + 1) % displayBufferSize; //  position next to displayBufferIndex in display buffer to copy from
+	// for (int i = 0; i < w; i++)
+	// {
+	//  float x = float(i);
 
-    if (valuesNeeded > 0 && valuesNeeded < 1000)
-    {
+	//  for (int n = 0; n < nChans; n++)
+	//  {
+	//      waves[n][i*2] = x;
+	//      waves[n][i*2+1] = 0.5f; // line in center of display
+	//  }
+	// }
 
-        for (int i = 0; i < valuesNeeded; i++) // also fill one extra sample for line drawing interpolation to match across draws
-        {
-            float gain = 1.0;
-            float alpha = (float) subSampleOffset;
-            float invAlpha = 1.0f - alpha;
+}
 
-            screenBuffer->clear(screenBufferIndex, 1);
+void LfpDisplayCanvas::updateScreenBuffer()
+{
 
-            displayBufferIndex = displayBufferIndex % displayBufferSize; // just to be sure
+	// copy new samples from the displayBuffer into the screenBuffer (waves)
+	int maxSamples = lfpDisplay->getWidth() - leftmargin;
 
-            for (int channel = 0; channel <= nChans; channel++) // pull one extra channel for event display
-            {
+	if (screenBufferIndex >= maxSamples) // wrap around if we reached right edge before
+		screenBufferIndex = 0;
 
-                screenBuffer->addFrom(channel, // destChannel
-                                      screenBufferIndex, // destStartSample
-                                      displayBuffer->getReadPointer(channel, displayBufferIndex), // source
-                                      1, // numSamples
-                                      invAlpha*gain); // gain
+	lastScreenBufferIndex = screenBufferIndex;
 
-                screenBuffer->addFrom(channel, // destChannel
-                                      screenBufferIndex, // destStartSample
-                                      displayBuffer->getReadPointer(channel, nextPos), // source
-                                      1, // numSamples
-                                      alpha*gain); // gain
+	int index = processor->getDisplayBufferIndex();
 
+	int nSamples =  index - displayBufferIndex; // N new samples (not pixels) to be added to displayBufferIndex
 
-            }
+	if (nSamples < 0) // buffer has reset to 0
+	{
+		nSamples = (displayBufferSize - displayBufferIndex) + index;
+	}
 
-            subSampleOffset += ratio;
+	float ratio = sampleRate * timebase / float(getWidth() - leftmargin - scrollBarThickness); // samples / pixel
+	// this number is crucial: converting from samples to values (in px) for the screen buffer
+	int valuesNeeded = (int) float(nSamples) / ratio; // N pixels needed for this update
 
-            while (subSampleOffset >= 1.0)
-            {
-                if (++displayBufferIndex > displayBufferSize)
-                    displayBufferIndex = 0;
+	if (screenBufferIndex + valuesNeeded > maxSamples)  // crop number of samples to fit cavas width
+	{
+		valuesNeeded = maxSamples - screenBufferIndex;
+	}
 
-                nextPos = (displayBufferIndex + 1) % displayBufferSize;
-                subSampleOffset -= 1.0;
-            }
+	float subSampleOffset = 0.0;
 
-            screenBufferIndex++;
+	displayBufferIndex = displayBufferIndex % displayBufferSize; // make sure we're not overshooting
+	int nextPos = (displayBufferIndex +1) % displayBufferSize; //  position next to displayBufferIndex in display buffer to copy from
 
-        }
+	if (valuesNeeded > 0 && valuesNeeded < 1000)
+	{
+		for (int i = 0; i < valuesNeeded; i++) // also fill one extra sample for line drawing interpolation to match across draws
+		{
+			//If paused don't update screen buffers, but update all indexes as needed
+			if (!lfpDisplay->isPaused)
+			{
+				float gain = 1.0;
+				float alpha = (float) subSampleOffset;
+				float invAlpha = 1.0f - alpha;
+
+				screenBuffer->clear(screenBufferIndex, 1);
+				screenBufferMin->clear(screenBufferIndex, 1);
+				screenBufferMean->clear(screenBufferIndex, 1);
+				screenBufferMax->clear(screenBufferIndex, 1);
+
+
+				displayBufferIndex = displayBufferIndex % displayBufferSize; // just to be sure
+
+				for (int channel = 0; channel <= nChans; channel++) // pull one extra channel for event display
+				{
+
+					// interpolate between two samples with invAlpha and alpha
+					screenBuffer->addFrom(channel, // destChannel
+						screenBufferIndex, // destStartSample
+						displayBuffer->getReadPointer(channel, displayBufferIndex), // source
+						1, // numSamples
+						invAlpha*gain); // gain
+
+
+					screenBuffer->addFrom(channel, // destChannel
+						screenBufferIndex, // destStartSample
+						displayBuffer->getReadPointer(channel, nextPos), // source
+						1, // numSamples
+						alpha*gain); // gain
+
+					// same thing again, but this time add the min,mean, and max of all samples in current pixel
+					float sample_min   =  1000000;
+					float sample_max   = -1000000;
+					float sample_mean  =  0;
+					int c=0;
+					int nextpix = (displayBufferIndex +(int)ratio) % displayBufferSize; //  position to next pixels index
+					for (int j = displayBufferIndex; j < nextpix; j++)
+					{
+						float sample_current = displayBuffer->getSample(channel, j);
+						sample_mean = sample_mean + sample_current;
+
+						if (sample_min>sample_current)
+						{
+							sample_min=sample_current;
+						}
+
+						if (sample_max<sample_current)
+						{
+							sample_max=sample_current;
+						}
+						c++;
+
+
+					}
+					sample_mean=sample_mean/c;
+					screenBufferMean->addSample(channel, screenBufferIndex, sample_mean*gain);
+					screenBufferMin->addSample(channel, screenBufferIndex, sample_min*gain);
+					screenBufferMax->addSample(channel, screenBufferIndex, sample_max*gain);
+
+				}
+				screenBufferIndex++;
+			}
+
+			subSampleOffset += ratio;
+
+			while (subSampleOffset >= 1.0)
+			{
+				if (++displayBufferIndex > displayBufferSize)
+					displayBufferIndex = 0;
+
+				nextPos = (displayBufferIndex + 1) % displayBufferSize;
+				subSampleOffset -= 1.0;
+			}
+
+		}
 
 
-    }
-    else
-    {
-        //std::cout << "Skip." << std::endl;
-    }
+	}
+	else
+	{
+		//std::cout << "Skip." << std::endl;
+	}
 }
 
 const float LfpDisplayCanvas::getXCoord(int chan, int samp)
 {
-    return samp;
+	return samp;
 }
 
 int LfpDisplayCanvas::getNumChannels()
 {
-    return nChans;
+	return nChans;
 }
 
 const float LfpDisplayCanvas::getYCoord(int chan, int samp)
 {
-    return *screenBuffer->getReadPointer(chan, samp);
+	return *screenBuffer->getReadPointer(chan, samp);
 }
 
+const float LfpDisplayCanvas::getYCoordMean(int chan, int samp)
+{
+	return *screenBufferMean->getReadPointer(chan, samp);
+}
+const float LfpDisplayCanvas::getYCoordMin(int chan, int samp)
+{
+	return *screenBufferMin->getReadPointer(chan, samp);
+}
+const float LfpDisplayCanvas::getYCoordMax(int chan, int samp)
+{
+	return *screenBufferMax->getReadPointer(chan, samp);
+}
+
+
 bool LfpDisplayCanvas::getInputInvertedState()
 {
-    return invertInputButton->getToggleState();
+	return invertInputButton->getToggleState();
+}
+
+bool LfpDisplayCanvas::getDrawMethodState()
+{
+	return drawMethodButton->getToggleState();
 }
 
 void LfpDisplayCanvas::paint(Graphics& g)
 {
 
-    //std::cout << "Painting" << std::endl;
-    g.setColour(Colour(0,18,43)); //background color
-    g.fillRect(0, 0, getWidth(), getHeight());
+	//std::cout << "Painting" << std::endl;
+	g.setColour(Colour(0,18,43)); //background color
+	g.fillRect(0, 0, getWidth(), getHeight());
 
-    g.setGradientFill(ColourGradient(Colour(50,50,50),0,0,
-                                     Colour(25,25,25),0,30,
-                                     false));
+	g.setGradientFill(ColourGradient(Colour(50,50,50),0,0,
+		Colour(25,25,25),0,30,
+		false));
 
-    g.fillRect(0, 0, getWidth()-scrollBarThickness, 30);
+	g.fillRect(0, 0, getWidth()-scrollBarThickness, 30);
 
-    g.setColour(Colours::black);
+	g.setColour(Colours::black);
 
-    g.drawLine(0,30,getWidth()-scrollBarThickness,30);
+	g.drawLine(0,30,getWidth()-scrollBarThickness,30);
 
-    g.setColour(Colour(25,25,60)); // timing grid color
+	g.setColour(Colour(25,25,60)); // timing grid color
 
-    int w = getWidth()-scrollBarThickness-leftmargin;
+	int w = getWidth()-scrollBarThickness-leftmargin;
+
+	for (int i = 0; i < 10; i++)
+	{
+		if (i == 5 || i == 0)
+			g.drawLine(w/10*i+leftmargin,0,w/10*i+leftmargin,getHeight()-60,3.0f);
+		else
+			g.drawLine(w/10*i+leftmargin,0,w/10*i+leftmargin,getHeight()-60,1.0f);
+	}
 
-    for (int i = 0; i < 10; i++)
-    {
-        if (i == 5 || i == 0)
-            g.drawLine(w/10*i+leftmargin,0,w/10*i+leftmargin,getHeight()-60,3.0f);
-        else
-            g.drawLine(w/10*i+leftmargin,0,w/10*i+leftmargin,getHeight()-60,1.0f);
-    }
+	g.drawLine(0,getHeight()-60,getWidth(),getHeight()-60,3.0f);
 
-    g.drawLine(0,getHeight()-60,getWidth(),getHeight()-60,3.0f);
+	g.setFont(Font("Default", 16, Font::plain));
 
-    g.setFont(Font("Default", 16, Font::plain));
+	g.setColour(Colour(100,100,100));
 
-    g.setColour(Colour(100,100,100));
+	g.drawText("Voltage range (uV)",5,getHeight()-55,300,20,Justification::left, false);
+	g.drawText("Timebase (s)",175,getHeight()-55,300,20,Justification::left, false);
+	g.drawText("Spread (px)",345,getHeight()-55,300,20,Justification::left, false);
+	g.drawText("Color grouping",620,getHeight()-55,300,20,Justification::left, false);
 
-    g.drawText("Voltage range (uV)",5,getHeight()-55,300,20,Justification::left, false);
-    g.drawText("Timebase (s)",175,getHeight()-55,300,20,Justification::left, false);
-    g.drawText("Spread (px)",345,getHeight()-55,300,20,Justification::left, false);
-    g.drawText("Color grouping",620,getHeight()-55,300,20,Justification::left, false);
-    
 
-    g.drawText("Event disp.",500,getHeight()-55,300,20,Justification::left, false);
+	g.drawText("Event disp.",500,getHeight()-55,300,20,Justification::left, false);
 
 
 
@@ -482,106 +611,137 @@ void LfpDisplayCanvas::paint(Graphics& g)
 
 void LfpDisplayCanvas::refresh()
 {
-    updateScreenBuffer();
 
-    lfpDisplay->refresh(); // redraws only the new part of the screen buffer
+	updateScreenBuffer(); 
 
-    //getPeer()->performAnyPendingRepaintsNow();
+	lfpDisplay->refresh(); // redraws only the new part of the screen buffer
 
+	//getPeer()->performAnyPendingRepaintsNow();
+
+}
+
+bool LfpDisplayCanvas::keyPressed(const KeyPress& key)
+{
+	if (key.getKeyCode() == key.spaceKey)
+	{
+		pauseButton->setToggleState(!pauseButton->getToggleState(),true);
+		return true;
+	}
+
+	return false;
+}
+
+bool LfpDisplayCanvas::keyPressed(const KeyPress& key, Component* orig)
+{
+	if (getTopLevelComponent() == orig && isVisible())
+	{
+		return keyPressed(key);
+	}
+	return false;
 }
 
 void LfpDisplayCanvas::saveVisualizerParameters(XmlElement* xml)
 {
 
-    XmlElement* xmlNode = xml->createNewChildElement("LFPDISPLAY");
+	XmlElement* xmlNode = xml->createNewChildElement("LFPDISPLAY");
 
 
-    xmlNode->setAttribute("Range",rangeSelection->getSelectedId());
-    xmlNode->setAttribute("Timebase",timebaseSelection->getSelectedId());
-    xmlNode->setAttribute("Spread",spreadSelection->getSelectedId());
-    xmlNode->setAttribute("colorGrouping",colorGroupingSelection->getSelectedId());
-    xmlNode->setAttribute("isInverted",invertInputButton->getToggleState());
+	xmlNode->setAttribute("Range",rangeSelection->getSelectedId());
+	xmlNode->setAttribute("Timebase",timebaseSelection->getSelectedId());
+	xmlNode->setAttribute("Spread",spreadSelection->getSelectedId());
+	xmlNode->setAttribute("colorGrouping",colorGroupingSelection->getSelectedId());
+	xmlNode->setAttribute("isInverted",invertInputButton->getToggleState());
+	xmlNode->setAttribute("drawMethod",drawMethodButton->getToggleState());
 
-    int eventButtonState = 0;
+	int eventButtonState = 0;
 
-    for (int i = 0; i < 8; i++)
-    {
-    	if (lfpDisplay->eventDisplayEnabled[i])
-    	{
-    		eventButtonState += (1 << i);
-    	}
-    }
+	for (int i = 0; i < 8; i++)
+	{
+		if (lfpDisplay->eventDisplayEnabled[i])
+		{
+			eventButtonState += (1 << i);
+		}
+	}
 
-    xmlNode->setAttribute("EventButtonState", eventButtonState);
+	xmlNode->setAttribute("EventButtonState", eventButtonState);
 
-    String channelDisplayState = "";
+	String channelDisplayState = "";
 
-    for (int i = 0; i < nChans; i++)
-    {
-    	if (lfpDisplay->getEnabledState(i))
-    	{
-    		channelDisplayState += "1";
-    	} else {
-    		channelDisplayState += "0";
-    	}
-    }
+	for (int i = 0; i < nChans; i++)
+	{
+		if (lfpDisplay->getEnabledState(i))
+		{
+			channelDisplayState += "1";
+		}
+		else
+		{
+			channelDisplayState += "0";
+		}
+	}
 
-    xmlNode->setAttribute("ChannelDisplayState", channelDisplayState);
+	xmlNode->setAttribute("ChannelDisplayState", channelDisplayState);
 
-    xmlNode->setAttribute("ScrollX",viewport->getViewPositionX());
-    xmlNode->setAttribute("ScrollY",viewport->getViewPositionY());
+	xmlNode->setAttribute("ScrollX",viewport->getViewPositionX());
+	xmlNode->setAttribute("ScrollY",viewport->getViewPositionY());
 }
 
 
 void LfpDisplayCanvas::loadVisualizerParameters(XmlElement* xml)
 {
-    forEachXmlChildElement(*xml, xmlNode)
-    {
-        if (xmlNode->hasTagName("LFPDISPLAY"))
-        {
-            rangeSelection->setSelectedId(xmlNode->getIntAttribute("Range"));
-            timebaseSelection->setSelectedId(xmlNode->getIntAttribute("Timebase"));
-            spreadSelection->setSelectedId(xmlNode->getIntAttribute("Spread"));
-            if (xmlNode->hasAttribute("colorGrouping")) {
-                colorGroupingSelection->setSelectedId(xmlNode->getIntAttribute("colorGrouping"));
-            } else {
-                colorGroupingSelection->setSelectedId(1);
-            }
-
-            invertInputButton->setToggleState(xmlNode->getBoolAttribute("isInverted", true), sendNotification);
-
-            viewport->setViewPosition(xmlNode->getIntAttribute("ScrollX"),
-                                      xmlNode->getIntAttribute("ScrollY"));
-
-            int eventButtonState = xmlNode->getIntAttribute("EventButtonState");
-
-            for (int i = 0; i < 8; i++)
-            {
-            	lfpDisplay->eventDisplayEnabled[i] = (eventButtonState >> i) & 1;
-
-            	eventDisplayInterfaces[i]->checkEnabledState();
-            }
-
-            String channelDisplayState = xmlNode->getStringAttribute("ChannelDisplayState");
-
-            for (int i = 0; i < channelDisplayState.length(); i++)
-            {
-
-            	if (channelDisplayState.substring(i,i+1).equalsIgnoreCase("1"))
-            	{
-            		//std::cout << "LfpDisplayCanvas enabling channel " << i << std::endl;
-            		lfpDisplay->enableChannel(true, i);
-            		isChannelEnabled.set(i,true); //lfpDisplay->enableChannel(true, i);
-            	} else {
-            		//std::cout << "LfpDisplayCanvas disabling channel " << i << std::endl;
-            		lfpDisplay->enableChannel(false, i);
-            		isChannelEnabled.set(i,false); 
-            	}
-
-            	
-            }
-        }
-    }
+	forEachXmlChildElement(*xml, xmlNode)
+	{
+		if (xmlNode->hasTagName("LFPDISPLAY"))
+		{
+			rangeSelection->setSelectedId(xmlNode->getIntAttribute("Range"));
+			timebaseSelection->setSelectedId(xmlNode->getIntAttribute("Timebase"));
+			spreadSelection->setSelectedId(xmlNode->getIntAttribute("Spread"));
+			if (xmlNode->hasAttribute("colorGrouping"))
+			{
+				colorGroupingSelection->setSelectedId(xmlNode->getIntAttribute("colorGrouping"));
+			}
+			else
+			{
+				colorGroupingSelection->setSelectedId(1);
+			}
+
+			invertInputButton->setToggleState(xmlNode->getBoolAttribute("isInverted", true), sendNotification);
+
+			drawMethodButton->setToggleState(xmlNode->getBoolAttribute("drawMethod", true), sendNotification);
+
+			viewport->setViewPosition(xmlNode->getIntAttribute("ScrollX"),
+				xmlNode->getIntAttribute("ScrollY"));
+
+			int eventButtonState = xmlNode->getIntAttribute("EventButtonState");
+
+			for (int i = 0; i < 8; i++)
+			{
+				lfpDisplay->eventDisplayEnabled[i] = (eventButtonState >> i) & 1;
+
+				eventDisplayInterfaces[i]->checkEnabledState();
+			}
+
+			String channelDisplayState = xmlNode->getStringAttribute("ChannelDisplayState");
+
+			for (int i = 0; i < channelDisplayState.length(); i++)
+			{
+
+				if (channelDisplayState.substring(i,i+1).equalsIgnoreCase("1"))
+				{
+					//std::cout << "LfpDisplayCanvas enabling channel " << i << std::endl;
+					lfpDisplay->enableChannel(true, i);
+					isChannelEnabled.set(i,true); //lfpDisplay->enableChannel(true, i);
+				}
+				else
+				{
+					//std::cout << "LfpDisplayCanvas disabling channel " << i << std::endl;
+					lfpDisplay->enableChannel(false, i);
+					isChannelEnabled.set(i,false);
+				}
+
+
+			}
+		}
+	}
 
 }
 
@@ -591,7 +751,7 @@ void LfpDisplayCanvas::loadVisualizerParameters(XmlElement* xml)
 LfpTimescale::LfpTimescale(LfpDisplayCanvas* c) : canvas(c)
 {
 
-    font = Font("Default", 16, Font::plain);
+	font = Font("Default", 16, Font::plain);
 }
 
 LfpTimescale::~LfpTimescale()
@@ -604,38 +764,38 @@ void LfpTimescale::paint(Graphics& g)
 
 
 
-    g.setFont(font);
+	g.setFont(font);
 
-    g.setColour(Colour(100,100,100));
+	g.setColour(Colour(100,100,100));
 
-    g.drawText("ms:",5,0,100,getHeight(),Justification::left, false);
+	g.drawText("ms:",5,0,100,getHeight(),Justification::left, false);
 
-    for (int i = 1; i < 10; i++)
-    {
-        if (i == 5)
-            g.drawLine(getWidth()/10*i,0,getWidth()/10*i,getHeight(),3.0f);
-        else
-            g.drawLine(getWidth()/10*i,0,getWidth()/10*i,getHeight(),1.0f);
+	for (int i = 1; i < 10; i++)
+	{
+		if (i == 5)
+			g.drawLine(getWidth()/10*i,0,getWidth()/10*i,getHeight(),3.0f);
+		else
+			g.drawLine(getWidth()/10*i,0,getWidth()/10*i,getHeight(),1.0f);
 
-        g.drawText(labels[i-1],getWidth()/10*i+3,0,100,getHeight(),Justification::left, false);
-    }
+		g.drawText(labels[i-1],getWidth()/10*i+3,0,100,getHeight(),Justification::left, false);
+	}
 
 }
 
 void LfpTimescale::setTimebase(float t)
 {
-    timebase = t;
+	timebase = t;
 
-    labels.clear();
+	labels.clear();
 
-    for (float i = 1.0f; i < 10.0; i++)
-    {
-        String labelString = String(timebase/10.0f*1000.0f*i);
+	for (float i = 1.0f; i < 10.0; i++)
+	{
+		String labelString = String(timebase/10.0f*1000.0f*i);
 
-        labels.add(labelString.substring(0,4));
-    }
+		labels.add(labelString.substring(0,4));
+	}
 
-    repaint();
+	repaint();
 
 }
 
@@ -643,164 +803,169 @@ void LfpTimescale::setTimebase(float t)
 // ---------------------------------------------------------------
 
 LfpDisplay::LfpDisplay(LfpDisplayCanvas* c, Viewport* v) :
-    canvas(c), viewport(v), range(1000.0f)
+	canvas(c), viewport(v), range(1000.0f), singleChan(-1)
 {
 
-    totalHeight = 0;
-    colorGrouping=1;
+	totalHeight = 0;
+	colorGrouping=1;
 
-    addMouseListener(this, true);
+	addMouseListener(this, true);
 
-    // hue cycle
-    //for (int i = 0; i < 15; i++)
-    //{
-    //    channelColours.add(Colour(float(sin((3.14/2)*(float(i)/15))),float(1.0),float(1),float(1.0)));
-    //}
+	// hue cycle
+	//for (int i = 0; i < 15; i++)
+	//{
+	//    channelColours.add(Colour(float(sin((3.14/2)*(float(i)/15))),float(1.0),float(1),float(1.0)));
+	//}
 
-    //hand-built palette
-    channelColours.add(Colour(224,185,36));
-    channelColours.add(Colour(214,210,182));
-    channelColours.add(Colour(243,119,33));
-    channelColours.add(Colour(186,157,168));
-    channelColours.add(Colour(237,37,36));
-    channelColours.add(Colour(179,122,79));
-    channelColours.add(Colour(217,46,171));
-    channelColours.add(Colour(217, 139,196));
-    channelColours.add(Colour(101,31,255));
-    channelColours.add(Colour(141,111,181));
-    channelColours.add(Colour(48,117,255));
-    channelColours.add(Colour(184,198,224));
-    channelColours.add(Colour(116,227,156));
-    channelColours.add(Colour(150,158,155));
-    channelColours.add(Colour(82,173,0));
-    channelColours.add(Colour(125,99,32));
+	//hand-built palette
+	channelColours.add(Colour(224,185,36));
+	channelColours.add(Colour(214,210,182));
+	channelColours.add(Colour(243,119,33));
+	channelColours.add(Colour(186,157,168));
+	channelColours.add(Colour(237,37,36));
+	channelColours.add(Colour(179,122,79));
+	channelColours.add(Colour(217,46,171));
+	channelColours.add(Colour(217, 139,196));
+	channelColours.add(Colour(101,31,255));
+	channelColours.add(Colour(141,111,181));
+	channelColours.add(Colour(48,117,255));
+	channelColours.add(Colour(184,198,224));
+	channelColours.add(Colour(116,227,156));
+	channelColours.add(Colour(150,158,155));
+	channelColours.add(Colour(82,173,0));
+	channelColours.add(Colour(125,99,32));
+
+	isPaused=false;
 
 }
 
 LfpDisplay::~LfpDisplay()
 {
-    deleteAllChildren();
+	deleteAllChildren();
 }
 
 
 
 int LfpDisplay::getNumChannels()
 {
-    return numChans;
+	return numChans;
 }
 
 
 
 int LfpDisplay::getColorGrouping()
 {
-    return colorGrouping;
+	return colorGrouping;
 }
 
 void LfpDisplay::setColorGrouping(int i)
 {
-    colorGrouping=i;
-    setColors(); // so that channel colors get re-assigned 
-    
+	colorGrouping=i;
+	setColors(); // so that channel colors get re-assigned
+
 }
 
 
 void LfpDisplay::setNumChannels(int numChannels)
 {
-    numChans = numChannels;
+	numChans = numChannels;
 
-    deleteAllChildren();
+	deleteAllChildren();
 
-    channels.clear();
-    channelInfo.clear();
+	channels.clear();
+	channelInfo.clear();
 
-    totalHeight = 0;
+	totalHeight = 0;
 
-    for (int i = 0; i < numChans; i++)
-    {
+	for (int i = 0; i < numChans; i++)
+	{
 
 		//std::cout << "Adding new display for channel " << i << std::endl;
 
-        LfpChannelDisplay* lfpChan = new LfpChannelDisplay(canvas, this, i);
+		LfpChannelDisplay* lfpChan = new LfpChannelDisplay(canvas, this, i);
 
-        //lfpChan->setColour(channelColours[i % channelColours.size()]);
-        lfpChan->setRange(range);
-        lfpChan->setChannelHeight(canvas->getChannelHeight());
+		//lfpChan->setColour(channelColours[i % channelColours.size()]);
+		lfpChan->setRange(range);
+		lfpChan->setChannelHeight(canvas->getChannelHeight());
 
-        addAndMakeVisible(lfpChan);
+		addAndMakeVisible(lfpChan);
 
-        channels.add(lfpChan);
+		channels.add(lfpChan);
 
-        LfpChannelDisplayInfo* lfpInfo = new LfpChannelDisplayInfo(canvas, this, i);
+		LfpChannelDisplayInfo* lfpInfo = new LfpChannelDisplayInfo(canvas, this, i);
 
-        //lfpInfo->setColour(channelColours[i % channelColours.size()]);
-        lfpInfo->setRange(range);
-        lfpInfo->setChannelHeight(canvas->getChannelHeight());
+		//lfpInfo->setColour(channelColours[i % channelColours.size()]);
+		lfpInfo->setRange(range);
+		lfpInfo->setChannelHeight(canvas->getChannelHeight());
 
-        addAndMakeVisible(lfpInfo);
+		addAndMakeVisible(lfpInfo);
 
-        channelInfo.add(lfpInfo);
+		channelInfo.add(lfpInfo);
 
-        totalHeight += lfpChan->getChannelHeight();
+		totalHeight += lfpChan->getChannelHeight();
 
-    }
+	}
 
-    setColors();
+	setColors();
 
-    //std::cout << "TOTAL HEIGHT = " << totalHeight << std::endl;
+	//std::cout << "TOTAL HEIGHT = " << totalHeight << std::endl;
 
-    // // this doesn't seem to do anything:
-    //canvas->fullredraw = true;
-    //refresh();
+	// // this doesn't seem to do anything:
+	//canvas->fullredraw = true;
+	//refresh();
 
 }
 
 void LfpDisplay::setColors()
 {
-   for (int i = 0; i < numChans; i++)
-    {
+	for (int i = 0; i < numChans; i++)
+	{
 
-        channels[i]->setColour(channelColours[(int(i/colorGrouping)+1) % channelColours.size()]);        
-        channelInfo[i]->setColour(channelColours[(int(i/colorGrouping)+1)  % channelColours.size()]);
-    }
+		channels[i]->setColour(channelColours[(int(i/colorGrouping)+1) % channelColours.size()]);
+		channelInfo[i]->setColour(channelColours[(int(i/colorGrouping)+1)  % channelColours.size()]);
+	}
 
 }
 
 
 int LfpDisplay::getTotalHeight()
 {
-    return totalHeight;
+	return totalHeight;
 }
 
 void LfpDisplay::resized()
 {
 
-    int totalHeight = 0;
+	int totalHeight = 0;
 
-    for (int i = 0; i < channels.size(); i++)
-    {
+	for (int i = 0; i < channels.size(); i++)
+	{
 
-        LfpChannelDisplay* disp = channels[i];
+		LfpChannelDisplay* disp = channels[i];
 
-        disp->setBounds(canvas->leftmargin,
-                        totalHeight-disp->getChannelOverlap()/2,
-                        getWidth(),
-                        disp->getChannelHeight()+disp->getChannelOverlap());
+		disp->setBounds(canvas->leftmargin,
+			totalHeight-disp->getChannelOverlap()/2,
+			getWidth(),
+			disp->getChannelHeight()+disp->getChannelOverlap());
 
-        LfpChannelDisplayInfo* info = channelInfo[i];
+		LfpChannelDisplayInfo* info = channelInfo[i];
 
-        info->setBounds(0,
-                        totalHeight-disp->getChannelHeight()/4,
-                        canvas->leftmargin,
-                        disp->getChannelHeight());
+		info->setBounds(0,
+			totalHeight-disp->getChannelHeight()/4,
+			canvas->leftmargin,
+			disp->getChannelHeight());
 
-        totalHeight += disp->getChannelHeight();
+		totalHeight += disp->getChannelHeight();
+		
+	}
 
-    }
+	canvas->fullredraw = true; //issue full redraw
+	if (singleChan != -1)
+		viewport->setViewPosition(Point<int>(0,singleChan*getChannelHeight()));
 
-    canvas->fullredraw = true; //issue full redraw
-    refresh();
+	refresh();
 
-    // std::cout << "Total height: " << totalHeight << std::endl;
+	// std::cout << "Total height: " << totalHeight << std::endl;
 
 }
 
@@ -813,82 +978,105 @@ void LfpDisplay::refresh()
 {
 
 
-    int topBorder = viewport->getViewPositionY();
-    int bottomBorder = viewport->getViewHeight() + topBorder;
-
-    // ensure that only visible channels are redrawn
-    for (int i = 0; i < numChans; i++)
-    {
+	int topBorder = viewport->getViewPositionY();
+	int bottomBorder = viewport->getViewHeight() + topBorder;
 
-        int componentTop = channels[i]->getY();
-        int componentBottom = channels[i]->getHeight() + componentTop;
-
-        if ((topBorder <= componentBottom && bottomBorder >= componentTop))
-        {
-            if (canvas->fullredraw)
-            {
-                channels[i]->fullredraw = true;
-                channels[i]->repaint();
-                channelInfo[i]->repaint();
+	// ensure that only visible channels are redrawn
+	for (int i = 0; i < numChans; i++)
+	{
 
-            }
-            else
-            {
-                channels[i]->repaint(canvas->lastScreenBufferIndex-2, 0, (canvas->screenBufferIndex-canvas->lastScreenBufferIndex)+3, getChildComponent(i)->getHeight());  //repaint only the updated portion
-                // we redraw from -2 to +1 relative to the real redraw window, the -2 makes sure that the lines join nicely, and the +1 draws the vertical update line
-            }
-            //std::cout << i << std::endl;
-        }
+		int componentTop = channels[i]->getY();
+		int componentBottom = channels[i]->getHeight() + componentTop;
+
+		if ((topBorder <= componentBottom && bottomBorder >= componentTop))
+		{
+			if (canvas->fullredraw)
+			{
+				channels[i]->fullredraw = true;
+				channels[i]->repaint();
+				channelInfo[i]->repaint();
+
+			}
+			else
+			{
+				channels[i]->repaint(canvas->lastScreenBufferIndex-2, 0, (canvas->screenBufferIndex-canvas->lastScreenBufferIndex)+3, getChildComponent(i)->getHeight());  //repaint only the updated portion
+				// we redraw from -2 to +1 relative to the real redraw window, the -2 makes sure that the lines join nicely, and the +1 draws the vertical update line
+			}
+			//std::cout << i << std::endl;
+		}
 
-    }
+	}
 
-    canvas->fullredraw = false;
+	canvas->fullredraw = false;
 }
 
 void LfpDisplay::setRange(float r)
 {
-    range = r;
+	range = r;
 
-    for (int i = 0; i < numChans; i++)
-    {
-        channels[i]->setRange(range);
-    }
+	for (int i = 0; i < numChans; i++)
+	{
+		channels[i]->setRange(range);
+	}
+	canvas->fullredraw = true; //issue full redraw
 }
 
 int LfpDisplay::getRange()
 {
-    return channels[0]->getRange();
+	return channels[0]->getRange();
 }
 
 
-void LfpDisplay::setChannelHeight(int r)
+void LfpDisplay::setChannelHeight(int r, bool resetSingle)
 {
 
-    for (int i = 0; i < numChans; i++)
-    {
-        channels[i]->setChannelHeight(r);
-        channelInfo[i]->setChannelHeight(r);
-    }
+	for (int i = 0; i < numChans; i++)
+	{
+		channels[i]->setChannelHeight(r);
+		channelInfo[i]->setChannelHeight(r);
+	}
+	if (resetSingle && singleChan != -1)
+	{
+		setSize(getWidth(),numChans*getChannelHeight());
+		viewport->setScrollBarsShown(true,false);
+		viewport->setViewPosition(Point<int>(0,singleChan*r));
+		singleChan = -1;
+		for (int n = 0; n < numChans; n++)
+		{
+			channelInfo[n]->setEnabledState(true);
+		}
+	}
 
-    resized();
+	resized();
 
 }
 
 void LfpDisplay::setInputInverted(bool isInverted)
 {
 
-    for (int i = 0; i < numChans; i++)
-    {
-        channels[i]->setInputInverted(isInverted);
-    }
+	for (int i = 0; i < numChans; i++)
+	{
+		channels[i]->setInputInverted(isInverted);
+	}
+
+	resized();
+
+}
 
-    resized();
+void LfpDisplay::setDrawMethod(bool isDrawMethod)
+{
+	for (int i = 0; i < numChans; i++)
+	{
+		channels[i]->setDrawMethod(isDrawMethod);
+	}
+	resized();
 
 }
 
+
 int LfpDisplay::getChannelHeight()
 {
-    return channels[0]->getChannelHeight();
+	return channels[0]->getChannelHeight();
 }
 
 
@@ -896,103 +1084,148 @@ int LfpDisplay::getChannelHeight()
 void LfpDisplay::mouseWheelMove(const MouseEvent&  e, const MouseWheelDetails&   wheel)
 {
 
-    //std::cout << "Mouse wheel " <<  e.mods.isCommandDown() << "  " << wheel.deltaY << std::endl;
-
-    if (e.mods.isCommandDown())  // CTRL + scroll wheel -> change channel spacing
-    {
-        //
-        // this should also scroll to keep the selected channel at a constant y!
-        //
-        int h = getChannelHeight();
-        if (wheel.deltaY>0)
-        {
-            setChannelHeight(h+1);
-        }
-        else
-        {
-            if (h>5)
-                setChannelHeight(h-1);
-        }
-    }
-    else
-    {
-        if (e.mods.isShiftDown())  // SHIFT + scroll wheel -> change channel range
-        {
-            int h= getRange();
-            if (wheel.deltaY>0)
-            {
-                setRange(h+10);
-            }
-            else
-            {
-                if (h>11)
-                    setRange(h-10);
-            }
-
-        }
-        else    // just scroll
-        {
-            //  passes the event up to the viewport so the screen scrolls
-            if (viewport != nullptr && e.eventComponent == this) // passes only if it's not a listening event
-                viewport->mouseWheelMove(e.getEventRelativeTo(canvas), wheel);
-
-        }
-    }
-
-    canvas->fullredraw = true;//issue full redraw
-
-    refresh();
+	//std::cout << "Mouse wheel " <<  e.mods.isCommandDown() << "  " << wheel.deltaY << std::endl;
+	
+	if (e.mods.isCommandDown())  // CTRL + scroll wheel -> change channel spacing
+	{
+		int h = getChannelHeight();
+		int hdiff=0;
+		if (wheel.deltaY>0)
+		{
+			hdiff=2;
+		}
+		else
+		{
+			if (h>5)
+				hdiff=-2;
+		}
+
+		if (abs(h)>100) // accelerate scrolling for large ranges
+			hdiff=hdiff*3;
+
+		setChannelHeight(h+hdiff);
+		int oldX=viewport->getViewPositionX();
+		int oldY=viewport->getViewPositionY();
+
+		setBounds(0,0,getWidth()-0, getChannelHeight()*canvas->nChans); // update height so that the scrollbar is correct
+
+		int mouseY=e.getMouseDownY(); // should be y pos relative to inner viewport (0,0)
+		int scrollBy = (mouseY/h)*hdiff*2;// compensate for motion of point under current mouse position
+		viewport->setViewPosition(oldX,oldY+scrollBy); // set back to previous position plus offset
+
+		canvas->setSpreadSelection(h+hdiff); // update combobox
+
+	}
+	else
+	{
+		if (e.mods.isShiftDown())  // SHIFT + scroll wheel -> change channel range
+		{
+			int h= getRange();
+			if (wheel.deltaY>0)
+			{
+				setRange(h+10);
+			}
+			else
+			{
+				if (h>11)
+					setRange(h-10);
+			}
+			
+			canvas->setRangeSelection(h); // update combobox
+
+		}
+		else    // just scroll
+		{
+			//  passes the event up to the viewport so the screen scrolls
+			if (viewport != nullptr && e.eventComponent == this) // passes only if it's not a listening event
+				viewport->mouseWheelMove(e.getEventRelativeTo(canvas), wheel);
+
+		}
+	}
+
+	canvas->fullredraw = true;//issue full redraw
+	refresh();
+
+}
+
+void LfpDisplay::toggleSingleChannel(int chan)
+{
+	std::cout << "Toggle channel " << chan << std::endl;
+	if (chan != singleChan)
+	{
+		singleChan = chan;
+		int newHeight = viewport->getHeight();
+		setChannelHeight(newHeight,false);
+		setSize(getWidth(),numChans*getChannelHeight());
+		viewport->setScrollBarsShown(false,false);
+		//viewport->setViewPosition(Point<int>(0,chan*newHeight));
+		for (int n = 0; n < numChans; n++)
+		{
+			if ( n != chan) channelInfo[n]->setEnabledState(false);
+		}
+
+	}
+	else
+	{
+		setChannelHeight(canvas->getChannelHeight());
+	}
+}
 
+bool LfpDisplay::getSingleChannelState()
+{
+	if (singleChan < 0) return false;
+	else return true;
 }
 
 
 void LfpDisplay::mouseDown(const MouseEvent& event)
 {
-    //int y = event.getMouseDownY(); //relative to each channel pos
-    MouseEvent canvasevent = event.getEventRelativeTo(viewport);
-    int y = canvasevent.getMouseDownY() + viewport->getViewPositionY(); // need to account for scrolling
+	//int y = event.getMouseDownY(); //relative to each channel pos
+	MouseEvent canvasevent = event.getEventRelativeTo(viewport);
+	int y = canvasevent.getMouseDownY() + viewport->getViewPositionY(); // need to account for scrolling
 
-    int dist=0;
-    int mindist=10000;
-    int closest=5;
-    for (int n = 0; n < numChans; n++) // select closest instead of relying ot eventComponent
-    {
-        channels[n]->deselect();
+	int dist=0;
+	int mindist=10000;
+	int closest=5;
+	for (int n = 0; n < numChans; n++) // select closest instead of relying ot eventComponent
+	{
+		channels[n]->deselect();
 
-        int cpos=(channels[n]->getY() + (channels[n]->getHeight()/2));
-        dist=int(abs(y - cpos));
+		int cpos=(channels[n]->getY() + (channels[n]->getHeight()/2));
+		dist=int(abs(y - cpos));
 
-        //std::cout << "Mouse down at " << y << " pos is "<< cpos << "n:" << n << "  dist " << dist << std::endl;
+		//std::cout << "Mouse down at " << y << " pos is "<< cpos << "n:" << n << "  dist " << dist << std::endl;
 
-        if (dist<mindist)
-        {
-            mindist=dist-1;
-            closest=n;
-        }
-    }
+		if (dist<mindist)
+		{
+			mindist=dist-1;
+			closest=n;
+		}
+	}
 
-    //LfpChannelDisplay* lcd = (LfpChannelDisplay*) event.eventComponent;
-    //lcd->select();
+	//LfpChannelDisplay* lcd = (LfpChannelDisplay*) event.eventComponent;
+	//lcd->select();
 
-    channels[closest]->select();
+	channels[closest]->select();
+	if (event.getNumberOfClicks() == 2) toggleSingleChannel(closest);
 
-    canvas->fullredraw = true;//issue full redraw
+	canvas->fullredraw = true;//issue full redraw
 
-    refresh();
+	refresh();
 
 }
 
 
 bool LfpDisplay::setEventDisplayState(int ch, bool state)
 {
-    eventDisplayEnabled[ch] = state;
-    return eventDisplayEnabled[ch];
+	eventDisplayEnabled[ch] = state;
+	return eventDisplayEnabled[ch];
 }
 
 
 bool LfpDisplay::getEventDisplayState(int ch)
 {
-    return eventDisplayEnabled[ch];
+	return eventDisplayEnabled[ch];
 }
 
 void LfpDisplay::enableChannel(bool state, int chan)
@@ -1015,34 +1248,34 @@ void LfpDisplay::setEnabledState(bool state, int chan)
 	}
 }
 
- bool LfpDisplay::getEnabledState(int chan)
- {
- 	if (chan < numChans)
- 	{
- 		return channels[chan]->getEnabledState();
- 	}
+bool LfpDisplay::getEnabledState(int chan)
+{
+	if (chan < numChans)
+	{
+		return channels[chan]->getEnabledState();
+	}
 
- 	return false;
- }
+	return false;
+}
 
 
 // ------------------------------------------------------------------
 
 LfpChannelDisplay::LfpChannelDisplay(LfpDisplayCanvas* c, LfpDisplay* d, int channelNumber) :
-    canvas(c), display(d), isSelected(false), chan(channelNumber), 
-    channelOverlap(300), channelHeight(40), range(1000.0f),
-    isEnabled(true), inputInverted(false), canBeInverted(true)
+	canvas(c), display(d), isSelected(false), chan(channelNumber),
+	channelOverlap(300), channelHeight(40), range(1000.0f),
+	isEnabled(true), inputInverted(false), canBeInverted(true), drawMethod(false)
 {
 
 
-    name = String(channelNumber+1); // default is to make the channelNumber the name
+	name = String(channelNumber+1); // default is to make the channelNumber the name
 
 
-    channelHeightFloat = (float) channelHeight;
+	channelHeightFloat = (float) channelHeight;
 
-    channelFont = Font("Default", channelHeight*0.6, Font::plain);
+	channelFont = Font("Default", channelHeight*0.6, Font::plain);
 
-    lineColour = Colour(255,255,255);
+	lineColour = Colour(255,255,255);
 
 }
 
@@ -1066,136 +1299,146 @@ void LfpChannelDisplay::setEnabledState(bool state)
 void LfpChannelDisplay::paint(Graphics& g)
 {
 
-    //g.fillAll(Colours::grey);
-
-    g.setColour(Colours::yellow);   // draw most recent drawn sample position
-    g.drawLine(canvas->screenBufferIndex+1, 0, canvas->screenBufferIndex+1, getHeight());
-
-
-
-
-    //g.setColour(Colours::red); // draw oldest drawn sample position
-    //g.drawLine(canvas->lastScreenBufferIndex, 0, canvas->lastScreenBufferIndex, getHeight()-channelOverlap);
-
-    if (isEnabled)
-    {
-
-    int center = getHeight()/2;
-
-    if (isSelected)
-    {
-
-        g.setColour(Colours::lightgrey);
-        g.fillRect(0,center-channelHeight/2,10,channelHeight);
-        g.drawLine(0,center+channelHeight/2,getWidth(),center+channelHeight/2);
-        g.drawLine(0,center-channelHeight/2,getWidth(),center-channelHeight/2);
-
-        g.setColour(Colour(25,25,25));
-        g.drawLine(0,center+channelHeight/4,10,center+channelHeight/4);
-        g.drawLine(0,center-channelHeight/4,10,center-channelHeight/4);
-
-    }
-
+	//g.fillAll(Colours::grey);
 
-    g.setColour(Colour(40,40,40));
-    g.drawLine(0, getHeight()/2, getWidth(), getHeight()/2);
+	g.setColour(Colours::yellow);   // draw most recent drawn sample position
+	g.drawLine(canvas->screenBufferIndex+1, 0, canvas->screenBufferIndex+1, getHeight());
 
-    int stepSize = 1;
-    int from = 0; // for vertical line drawing in the LFP data
-    int to = 0;
 
-    //for (int i = 0; i < getWidth()-stepSize; i += stepSize) // redraw entire display
-    int ifrom = canvas->lastScreenBufferIndex - 3; // need to start drawing a bit before the actual redraw windowfor the interpolated line to join correctly
 
-    if (ifrom < 0)
-        ifrom = 0;
 
-    int ito = canvas->screenBufferIndex - 1;
+	//g.setColour(Colours::red); // draw oldest drawn sample position
+	//g.drawLine(canvas->lastScreenBufferIndex, 0, canvas->lastScreenBufferIndex, getHeight()-channelOverlap);
 
-    if (fullredraw)
-    {
-        ifrom = 0; //canvas->leftmargin;
-        ito = getWidth()-stepSize;
-        fullredraw = false;
-    }
-
-    for (int i = ifrom; i < ito ; i += stepSize) // redraw only changed portion
-    {
-
-        // draw event markers
-        int rawEventState = canvas->getYCoord(canvas->getNumChannels(), i);// get last channel+1 in buffer (represents events)
-        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
-                {
-                    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);
-                }
-            }
-        }
-
-        //std::cout << "e " << canvas->getYCoord(canvas->getNumChannels()-1, i) << std::endl;
-
-        g.setColour(lineColour);
-        g.setOpacity(1);
-
-        // drawLine makes for ok anti-aliased plots, but is pretty slow
-        g.drawLine(i,
-                   (canvas->getYCoord(chan, i)/range*channelHeightFloat)+getHeight()/2,
-                   i+stepSize,
-                   (canvas->getYCoord(chan, i+stepSize)/range*channelHeightFloat)+getHeight()/2);
-
-        if (false) // switched back to line drawing now that we only draw partial updates
-        {
-
-            // // pixel wise line plot has no anti-aliasing, but runs much faster
-            double a = (canvas->getYCoord(chan, i)/range*channelHeightFloat)+getHeight()/2;
-            double b = (canvas->getYCoord(chan, i+stepSize)/range*channelHeightFloat)+getHeight()/2;
-
-            if (a<b)
-            {
-                from = (a);
-                to = (b);
-            }
-            else
-            {
-                from = (b);
-                to = (a);
-            }
-
-            if ((to-from) < 40)  // if there is too much vertical range in one pixel, don't draw the full line for speed reasons
-            {
-                for (int j = from; j <= to; j += 1)
-                {
-                    g.setPixel(i,j);
-                }
-            }
-            else if ((to-from) < 100)
-            {
-                for (int j = from; j <= to; j += 2)
-                {
-                    g.setPixel(i,j);
-                }
-            }
-            else
-            {
-                g.setPixel(i,to);
-                g.setPixel(i,from);
-            }
-
-        }
+	if (isEnabled)
+	{
 
-    }
-}	
+		int center = getHeight()/2;
+
+		if (isSelected)
+		{
+
+			g.setColour(Colours::lightgrey);
+			g.fillRect(0,center-channelHeight/2,10,channelHeight);
+			g.drawLine(0,center+channelHeight/2,getWidth(),center+channelHeight/2);
+			g.drawLine(0,center-channelHeight/2,getWidth(),center-channelHeight/2);
+
+			g.setColour(Colour(25,25,25));
+			g.drawLine(0,center+channelHeight/4,10,center+channelHeight/4);
+			g.drawLine(0,center-channelHeight/4,10,center-channelHeight/4);
+
+		}
+
+
+		g.setColour(Colour(40,40,40));
+		g.drawLine(0, getHeight()/2, getWidth(), getHeight()/2);
+
+		int stepSize = 1;
+		int from = 0; // for vertical line drawing in the LFP data
+		int to = 0;
+
+		//for (int i = 0; i < getWidth()-stepSize; i += stepSize) // redraw entire display
+		int ifrom = canvas->lastScreenBufferIndex - 3; // need to start drawing a bit before the actual redraw windowfor the interpolated line to join correctly
+
+		if (ifrom < 0)
+			ifrom = 0;
+
+		int ito = canvas->screenBufferIndex - 1;
+
+		if (fullredraw)
+		{
+			ifrom = 0; //canvas->leftmargin;
+			ito = getWidth()-stepSize;
+			fullredraw = false;
+		}
+
+		for (int i = ifrom; i < ito ; i += stepSize) // redraw only changed portion
+		{
+
+			// draw event markers
+			int rawEventState = canvas->getYCoord(canvas->getNumChannels(), i);// get last channel+1 in buffer (represents events)
+			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
+					{
+						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);
+					}
+				}
+			}
+
+			//std::cout << "e " << canvas->getYCoord(canvas->getNumChannels()-1, i) << std::endl;
+			g.setColour(lineColour);
+
+			if (drawMethod) // switched between to line drawing and pixel wise drawing
+			{
+
+				// drawLine makes for ok anti-aliased plots, but is pretty slow
+				g.drawLine(i,
+					(canvas->getYCoord(chan, i)/range*channelHeightFloat)+getHeight()/2,
+					i+stepSize,
+					(canvas->getYCoord(chan, i+stepSize)/range*channelHeightFloat)+getHeight()/2);
+
+
+			}
+			else
+			{
+
+				// // pixel wise line plot has no anti-aliasing, but runs much faster
+				double a = (canvas->getYCoordMax(chan, i)/range*channelHeightFloat)+getHeight()/2;
+				double b = (canvas->getYCoordMin(chan, i)/range*channelHeightFloat)+getHeight()/2;
+				double m = (canvas->getYCoordMean(chan, i)/range*channelHeightFloat)+getHeight()/2;
+				if (a<b)
+				{
+					from = (a);
+					to = (b);
+				}
+				else
+				{
+					from = (b);
+					to = (a);
+				}
+
+				//g.setColour(lineColour.withMultipliedBrightness( 1+(((((float)(to-from)*range)/getHeight())-0.01)*2)  )); // make spikes etc slightly brighter
+
+
+				if ((to-from) < 200)  // if there is too much vertical range in one pixel, don't draw the full line for speed reasons
+				{
+					for (int j = from; j <= to; j += 1)
+					{
+						g.setPixel(i,j);
+					}
+				}
+				else if ((to-from) < 400)
+				{
+					for (int j = from; j <= to; j += 2)
+					{
+						g.setPixel(i,j);
+					}
+				}
+				else
+				{
+					g.setPixel(i,to);
+					g.setPixel(i,from);
+				}
+
+				//draw mean
+				//g.setColour(Colours::black);
+				//g.setPixel(i,m);
+
+			}
+
+		}
+	}
 
-    // g.setColour(lineColour.withAlpha(0.7f)); // alpha on seems to decrease draw speed
-    // g.setFont(channelFont);
-    //  g.setFont(channelHeightFloat*0.6);
+	// g.setColour(lineColour.withAlpha(0.7f)); // alpha on seems to decrease draw speed
+	// g.setFont(channelFont);
+	//  g.setFont(channelHeightFloat*0.6);
 
-    // g.drawText(String(chan+1), 10, center-channelHeight/2, 200, channelHeight, Justification::left, false);
+	// g.drawText(String(chan+1), 10, center-channelHeight/2, 200, channelHeight, Justification::left, false);
 
 
 }
@@ -1207,60 +1450,60 @@ void LfpChannelDisplay::paint(Graphics& g)
 
 void LfpChannelDisplay::setRange(float r)
 {
-    range = r;
+	range = r;
 
-    //std::cout << "Range: " << r << std::endl;
+	//std::cout << "Range: " << r << std::endl;
 }
 
 int LfpChannelDisplay::getRange()
 {
-    return range;
+	return range;
 }
 
 
 void LfpChannelDisplay::select()
 {
-    isSelected = true;
+	isSelected = true;
 }
 
 void LfpChannelDisplay::deselect()
 {
-    isSelected = false;
+	isSelected = false;
 }
 
 void LfpChannelDisplay::setColour(Colour c)
 {
-    lineColour = c;
+	lineColour = c;
 }
 
 
 void LfpChannelDisplay::setChannelHeight(int c)
 {
-    channelHeight = c;
+	channelHeight = c;
 
-    channelHeightFloat = (float) channelHeight;
+	channelHeightFloat = (float) channelHeight;
 
-    if (!inputInverted)
-        channelHeightFloat = -channelHeightFloat;
+	if (!inputInverted)
+		channelHeightFloat = -channelHeightFloat;
 
-    channelOverlap = channelHeight*5;
+	channelOverlap = channelHeight*5;
 }
 
 int LfpChannelDisplay::getChannelHeight()
 {
 
-    return channelHeight;
+	return channelHeight;
 }
 
 void LfpChannelDisplay::setChannelOverlap(int overlap)
 {
-    channelOverlap = overlap;
+	channelOverlap = overlap;
 }
 
 
 int LfpChannelDisplay::getChannelOverlap()
 {
-    return channelOverlap;
+	return channelOverlap;
 }
 
 void LfpChannelDisplay::setCanBeInverted(bool _canBeInverted)
@@ -1270,37 +1513,44 @@ void LfpChannelDisplay::setCanBeInverted(bool _canBeInverted)
 
 void LfpChannelDisplay::setInputInverted(bool isInverted)
 {
-    if (canBeInverted)
-    {
-        inputInverted = isInverted;
+	if (canBeInverted)
+	{
+		inputInverted = isInverted;
+		setChannelHeight(channelHeight);
+	}
+}
+
+void LfpChannelDisplay::setDrawMethod(bool isDrawMethod)
+{
+
+	drawMethod = isDrawMethod;
 
-        setChannelHeight(channelHeight);
-    }
 }
 
+
 void LfpChannelDisplay::setName(String name_)
 {
-    name = name_;
+	name = name_;
 }
 
 // -------------------------------
 
 LfpChannelDisplayInfo::LfpChannelDisplayInfo(LfpDisplayCanvas* canvas_, LfpDisplay* display_, int ch)
-    : LfpChannelDisplay(canvas_, display_, ch)
+	: LfpChannelDisplay(canvas_, display_, ch)
 {
 
 	chan = ch;
 
 	enableButton = new UtilityButton("CH"+String(ch+1), Font("Small Text", 13, Font::plain));
-    enableButton->setRadius(5.0f);
-    
-    enableButton->setEnabledState(true);
-    enableButton->setCorners(true, true, true, true);
-    enableButton->addListener(this);
-    enableButton->setClickingTogglesState(true);
-    enableButton->setToggleState(true, dontSendNotification);
+	enableButton->setRadius(5.0f);
+
+	enableButton->setEnabledState(true);
+	enableButton->setCorners(true, true, true, true);
+	enableButton->addListener(this);
+	enableButton->setClickingTogglesState(true);
+	enableButton->setToggleState(true, dontSendNotification);
 
-    addAndMakeVisible(enableButton);
+	addAndMakeVisible(enableButton);
 
 }
 
@@ -1315,9 +1565,9 @@ void LfpChannelDisplayInfo::buttonClicked(Button* button)
 
 	// if (state)
 	// {
-	// 	b->setLabel("ON");
+	//  b->setLabel("ON");
 	// } else {
-	// 	b->setLabel("OFF");
+	//  b->setLabel("OFF");
 	// }
 
 	std::cout << "Turn channel " << chan << " to " << button->getToggleState() << std::endl;
@@ -1332,16 +1582,16 @@ void LfpChannelDisplayInfo::setEnabledState(bool state)
 void LfpChannelDisplayInfo::paint(Graphics& g)
 {
 
-    int center = getHeight()/2;
+	int center = getHeight()/2;
 
-    g.setColour(lineColour);
+	g.setColour(lineColour);
 
-    g.fillRoundedRectangle(5,center-8,41,22,8.0f);
+	g.fillRoundedRectangle(5,center-8,41,22,8.0f);
 
-  //  g.setFont(channelFont);
-   // g.setFont(channelHeightFloat*0.3);
+	//  g.setFont(channelFont);
+	// g.setFont(channelHeightFloat*0.3);
 
-  //  g.drawText(name, 10, center-channelHeight/2, 200, channelHeight, Justification::left, false);
+	//  g.drawText(name, 10, center-channelHeight/2, 200, channelHeight, Justification::left, false);
 
 }
 
@@ -1357,22 +1607,22 @@ void LfpChannelDisplayInfo::resized()
 // Event display Options --------------------------------------------------------------------
 
 EventDisplayInterface::EventDisplayInterface(LfpDisplay* display_, LfpDisplayCanvas* canvas_, int chNum):
-    isEnabled(true), display(display_), canvas(canvas_)
+	isEnabled(true), display(display_), canvas(canvas_)
 {
 
-    channelNumber = chNum;
+	channelNumber = chNum;
 
-    chButton = new UtilityButton(String(channelNumber+1), Font("Small Text", 13, Font::plain));
-    chButton->setRadius(5.0f);
-    chButton->setBounds(4,4,14,14);
-    chButton->setEnabledState(true);
-    chButton->setCorners(true, false, true, false);
-    //chButton.color = display->channelColours[channelNumber*2];
-    chButton->addListener(this);
-    addAndMakeVisible(chButton);
+	chButton = new UtilityButton(String(channelNumber+1), Font("Small Text", 13, Font::plain));
+	chButton->setRadius(5.0f);
+	chButton->setBounds(4,4,14,14);
+	chButton->setEnabledState(true);
+	chButton->setCorners(true, false, true, false);
+	//chButton.color = display->channelColours[channelNumber*2];
+	chButton->addListener(this);
+	addAndMakeVisible(chButton);
 
 
-    checkEnabledState();
+	checkEnabledState();
 
 }
 
@@ -1383,24 +1633,24 @@ EventDisplayInterface::~EventDisplayInterface()
 
 void EventDisplayInterface::checkEnabledState()
 {
-    isEnabled = display->getEventDisplayState(channelNumber);
+	isEnabled = display->getEventDisplayState(channelNumber);
 
-    //repaint();
+	//repaint();
 }
 
 void EventDisplayInterface::buttonClicked(Button* button)
 {
-    checkEnabledState();
-    if (isEnabled)
-    {
-        display->setEventDisplayState(channelNumber, false);
-    }
-    else
-    {
-        display->setEventDisplayState(channelNumber, true);
-    }
+	checkEnabledState();
+	if (isEnabled)
+	{
+		display->setEventDisplayState(channelNumber, false);
+	}
+	else
+	{
+		display->setEventDisplayState(channelNumber, true);
+	}
 
-    repaint();
+	repaint();
 
 }
 
@@ -1408,15 +1658,15 @@ void EventDisplayInterface::buttonClicked(Button* button)
 void EventDisplayInterface::paint(Graphics& g)
 {
 
-    checkEnabledState();
+	checkEnabledState();
 
-    if (isEnabled)
-    {
-        g.setColour(display->channelColours[channelNumber*2]);
-        g.fillRoundedRectangle(2,2,18,18,5.0f);
-    }
+	if (isEnabled)
+	{
+		g.setColour(display->channelColours[channelNumber*2]);
+		g.fillRoundedRectangle(2,2,18,18,5.0f);
+	}
 
 
-    //g.drawText(String(channelNumber), 8, 2, 200, 15, Justification::left, false);
+	//g.drawText(String(channelNumber), 8, 2, 200, 15, Justification::left, false);
 
 }
diff --git a/Source/Processors/Visualization/LfpDisplayCanvas.h b/Source/Processors/Visualization/LfpDisplayCanvas.h
index a1bf1b6977d608710bdeba1028d8cc84611f2698..c22746500f63ebcb5089e79438f128a7531dd0fb 100755
--- a/Source/Processors/Visualization/LfpDisplayCanvas.h
+++ b/Source/Processors/Visualization/LfpDisplayCanvas.h
@@ -45,7 +45,8 @@ class EventDisplayInterface;
 
 class LfpDisplayCanvas : public Visualizer,
     public ComboBox::Listener,
-    public Button::Listener
+    public Button::Listener,
+    public KeyListener
 
 {
 public:
@@ -61,6 +62,9 @@ public:
     void setParameter(int, float);
     void setParameter(int, int, int, float) {}
 
+	void setRangeSelection(float range); // set range selection combo box to correct value if it has been changed by scolling etc.
+	void setSpreadSelection(int spread); // set spread selection combo box to correct value if it has been changed by scolling etc.
+
     void paint(Graphics& g);
 
     void refresh();
@@ -71,10 +75,15 @@ public:
 
     int getNumChannels();
     bool getInputInvertedState();
+    bool getDrawMethodState();
 
     const float getXCoord(int chan, int samp);
     const float getYCoord(int chan, int samp);
 
+    const float getYCoordMin(int chan, int samp);
+    const float getYCoordMean(int chan, int samp);
+    const float getYCoordMax(int chan, int samp);
+
     int screenBufferIndex;
     int lastScreenBufferIndex;
 
@@ -82,17 +91,21 @@ public:
     void buttonClicked(Button* button);
 
     void saveVisualizerParameters(XmlElement* xml);
-
     void loadVisualizerParameters(XmlElement* xml);
 
+    bool keyPressed(const KeyPress& key);
+    bool keyPressed(const KeyPress& key, Component* orig);
+
+
     //void scrollBarMoved(ScrollBar *scrollBarThatHasMoved, double newRangeStart);
 
     bool fullredraw; // used to indicate that a full redraw is required. is set false after each full redraw, there is a similar switch for ach ch display;
     static const int leftmargin=50; // left margin for lfp plots (so the ch number text doesnt overlap)
 
-
     Array<bool> isChannelEnabled;
 
+	int nChans;
+
 private:
 
     float sampleRate;
@@ -100,15 +113,22 @@ private:
     float displayGain;
     float timeOffset;
     //int spread ; // vertical spacing between channels
-    
+
 
     static const int MAX_N_CHAN = 256;  // maximum number of channels
     static const int MAX_N_SAMP = 5000; // maximum display size in pixels
     //float waves[MAX_N_CHAN][MAX_N_SAMP*2]; // we need an x and y point for each sample
 
     LfpDisplayNode* processor;
-    AudioSampleBuffer* displayBuffer;
-    AudioSampleBuffer* screenBuffer;
+    AudioSampleBuffer* displayBuffer; // sample wise data buffer for display
+    AudioSampleBuffer* screenBuffer; // subsampled buffer- one int per pixel
+
+    //'define 3 buffers for min mean and max for better plotting of spikes
+    // not pretty, but 'AudioSampleBuffer works only for channels X samples
+    AudioSampleBuffer* screenBufferMin; // like screenBuffer but holds min/mean/max values per pixel
+    AudioSampleBuffer* screenBufferMean; // like screenBuffer but holds min/mean/max values per pixel
+    AudioSampleBuffer* screenBufferMax; // like screenBuffer but holds min/mean/max values per pixel
+
     MidiBuffer* eventBuffer;
 
     ScopedPointer<LfpTimescale> timescale;
@@ -120,6 +140,8 @@ private:
     ScopedPointer<ComboBox> spreadSelection;
     ScopedPointer<ComboBox> colorGroupingSelection;
     ScopedPointer<UtilityButton> invertInputButton;
+    ScopedPointer<UtilityButton> drawMethodButton;
+    ScopedPointer<UtilityButton> pauseButton;
 
     StringArray voltageRanges;
     StringArray timebases;
@@ -134,9 +156,7 @@ private:
     int displayBufferIndex;
     int displayBufferSize;
 
-    int scrollBarThickness;
-
-    int nChans;
+	int scrollBarThickness;
 
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LfpDisplayCanvas);
 
@@ -188,9 +208,10 @@ public:
     void setRange(float range);
     int getRange();
 
-    void setChannelHeight(int r);
+    void setChannelHeight(int r, bool resetSingle = true);
     int getChannelHeight();
     void setInputInverted(bool);
+    void setDrawMethod(bool);
 
     void setColors();
 
@@ -204,14 +225,20 @@ public:
     bool getEnabledState(int);
     void enableChannel(bool, int);
 
+	bool getSingleChannelState();
+
     Array<Colour> channelColours;
 
     Array<LfpChannelDisplay*> channels;
     Array<LfpChannelDisplayInfo*> channelInfo;
 
     bool eventDisplayEnabled[8];
+    bool isPaused; // simple pause function, skips screen bufer updates
 
 private:
+	void toggleSingleChannel(int chan);
+	int singleChan;
+
     int numChans;
 
     int totalHeight;
@@ -219,10 +246,11 @@ private:
     int colorGrouping;
 
     LfpDisplayCanvas* canvas;
-    Viewport* viewport;    
+    Viewport* viewport;
 
     float range;
 
+
 };
 
 class LfpChannelDisplay : public Component
@@ -252,8 +280,13 @@ public:
     void setInputInverted(bool);
     void setCanBeInverted(bool);
 
+    void setDrawMethod(bool);
+
     void setEnabledState(bool);
-    bool getEnabledState() {return isEnabled;}
+    bool getEnabledState()
+    {
+        return isEnabled;
+    }
 
     bool fullredraw; // used to indicate that a full redraw is required. is set false after each full redraw
 
@@ -281,11 +314,12 @@ protected:
     bool isEnabled;
     bool inputInverted;
     bool canBeInverted;
+    bool drawMethod;
 
 };
 
 class LfpChannelDisplayInfo : public LfpChannelDisplay,
-                              public Button::Listener
+    public Button::Listener
 {
 public:
     LfpChannelDisplayInfo(LfpDisplayCanvas*, LfpDisplay*, int channelNumber);
@@ -299,9 +333,9 @@ public:
     void setEnabledState(bool);
 
 private:
-    
-    ScopedPointer<UtilityButton> enableButton;        
-                
+
+    ScopedPointer<UtilityButton> enableButton;
+
 };
 
 class EventDisplayInterface : public Component,
diff --git a/Source/Processors/Visualization/LfpTriggeredAverageCanvas.cpp b/Source/Processors/Visualization/LfpTriggeredAverageCanvas.cpp
index 1f69ae2decb74cb66bfc82f8dcd632422740242a..f27016100e5e0a1f1527a8a4dda0ad968ef3aad9 100755
--- a/Source/Processors/Visualization/LfpTriggeredAverageCanvas.cpp
+++ b/Source/Processors/Visualization/LfpTriggeredAverageCanvas.cpp
@@ -452,10 +452,10 @@ void LfpTriggeredAverageCanvas::saveVisualizerParameters(XmlElement* xml)
 
     for (int i = 0; i < 8; i++)
     {
-    	if (display->eventDisplayEnabled[i])
-    	{
-    		eventButtonState += (1 << i);
-    	}
+        if (display->eventDisplayEnabled[i])
+        {
+            eventButtonState += (1 << i);
+        }
     }
 
     xmlNode->setAttribute("EventButtonState", eventButtonState);
@@ -482,9 +482,9 @@ void LfpTriggeredAverageCanvas::loadVisualizerParameters(XmlElement* xml)
 
             for (int i = 0; i < 8; i++)
             {
-            	display->eventDisplayEnabled[i] = (eventButtonState >> i) & 1;
+                display->eventDisplayEnabled[i] = (eventButtonState >> i) & 1;
 
-            	LfpTriggeredAverageEventInterfaces[i]->checkEnabledState();
+                LfpTriggeredAverageEventInterfaces[i]->checkEnabledState();
             }
         }
     }
diff --git a/Source/Processors/Visualization/LfpTriggeredAverageCanvas.h b/Source/Processors/Visualization/LfpTriggeredAverageCanvas.h
index e141def278bac155858dc7d547b8555025c2d544..d4bfaee4b79da39fa2e51c28a29bd8f01a8d5dc6 100755
--- a/Source/Processors/Visualization/LfpTriggeredAverageCanvas.h
+++ b/Source/Processors/Visualization/LfpTriggeredAverageCanvas.h
@@ -200,7 +200,7 @@ private:
     int totalHeight;
 
     LfpTriggeredAverageCanvas* canvas;
-    Viewport* viewport;    
+    Viewport* viewport;
 
     float range;
 
diff --git a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp
index 3cfdf3fc35565ebf1322df8586989e144d0a3029..a2dcf5bda7aef0477cc095b0d6ea53a7b3aeba11 100755
--- a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp
+++ b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp
@@ -30,8 +30,8 @@ SpikeDisplayCanvas::SpikeDisplayCanvas(SpikeDisplayNode* n) :
 
     viewport = new Viewport();
     spikeDisplay = new SpikeDisplay(this, viewport);
-	thresholdCoordinator = new SpikeThresholdCoordinator();
-	spikeDisplay->registerThresholdCoordinator(thresholdCoordinator);
+    thresholdCoordinator = new SpikeThresholdCoordinator();
+    spikeDisplay->registerThresholdCoordinator(thresholdCoordinator);
 
     viewport->setViewedComponent(spikeDisplay, false);
     viewport->setScrollBarsShown(true, false);
@@ -43,11 +43,11 @@ SpikeDisplayCanvas::SpikeDisplayCanvas(SpikeDisplayNode* n) :
     clearButton->addListener(this);
     addAndMakeVisible(clearButton);
 
-	lockThresholdsButton = new UtilityButton("Lock Thresholds", Font("Small Text", 13, Font::plain));
-	lockThresholdsButton->setRadius(3.0f);
-	lockThresholdsButton->addListener(this);
-	lockThresholdsButton->setClickingTogglesState(true);
-	addAndMakeVisible(lockThresholdsButton);
+    lockThresholdsButton = new UtilityButton("Lock Thresholds", Font("Small Text", 13, Font::plain));
+    lockThresholdsButton->setRadius(3.0f);
+    lockThresholdsButton->addListener(this);
+    lockThresholdsButton->setClickingTogglesState(true);
+    addAndMakeVisible(lockThresholdsButton);
 
     invertSpikesButton = new UtilityButton("Invert Spikes", Font("Small Text", 13, Font::plain));
     invertSpikesButton->setRadius(3.0f);
@@ -98,16 +98,18 @@ void SpikeDisplayCanvas::update()
         for (int i = 0; i < nPlots; i++)
         {
             SpikePlot* sp = spikeDisplay->addSpikePlot(processor->getNumberOfChannelsForElectrode(i), i,
-                                       processor->getNameForElectrode(i));
+                                                       processor->getNameForElectrode(i));
             processor->addSpikePlotForElectrode(sp, i);
         }
-    } else {
+    }
+    else
+    {
         for (int i = 0; i < nPlots; i++)
         {
             processor->addSpikePlotForElectrode(spikeDisplay->getSpikePlot(i), i);
         }
     }
-    
+
     spikeDisplay->resized();
     spikeDisplay->repaint();
 }
@@ -127,7 +129,7 @@ void SpikeDisplayCanvas::resized()
 
     clearButton->setBounds(10, getHeight()-40, 100,20);
 
-	lockThresholdsButton->setBounds(130, getHeight()-40, 130,20);
+    lockThresholdsButton->setBounds(130, getHeight()-40, 130,20);
 
     invertSpikesButton->setBounds(270, getHeight()-40, 130,20);
 
@@ -179,10 +181,10 @@ void SpikeDisplayCanvas::buttonClicked(Button* button)
     {
         spikeDisplay->clear();
     }
-	else if (button == lockThresholdsButton)
-	{
-		thresholdCoordinator->setLockThresholds(button->getToggleState());
-	} 
+    else if (button == lockThresholdsButton)
+    {
+        thresholdCoordinator->setLockThresholds(button->getToggleState());
+    }
     else if (button == invertSpikesButton)
     {
         spikeDisplay->invertSpikes(button->getToggleState());
@@ -220,10 +222,10 @@ void SpikeDisplayCanvas::loadVisualizerParameters(XmlElement* xml)
             spikeDisplay->invertSpikes(xmlNode->getBoolAttribute("InvertSpikes"));
             invertSpikesButton->setToggleState(xmlNode->getBoolAttribute("InvertSpikes"), dontSendNotification);
             lockThresholdsButton->setToggleState(xmlNode->getBoolAttribute("LockThresholds"), sendNotification);
-        
+
             int plotIndex = -1;
 
-             forEachXmlChildElement(*xmlNode, plotNode)
+            forEachXmlChildElement(*xmlNode, plotNode)
             {
                 if (plotNode->hasTagName("PLOT"))
                 {
@@ -236,7 +238,7 @@ void SpikeDisplayCanvas::loadVisualizerParameters(XmlElement* xml)
 
                     forEachXmlChildElement(*plotNode, channelNode)
                     {
-                        
+
                         if (channelNode->hasTagName("AXIS"))
                         {
                             channelIndex++;
@@ -244,15 +246,15 @@ void SpikeDisplayCanvas::loadVisualizerParameters(XmlElement* xml)
                             std::cout << "CHANNEL NUMBER " << channelIndex << std::endl;
 
                             spikeDisplay->setThresholdForWaveAxis(plotIndex,
-                                    channelIndex, 
-                                    channelNode->getDoubleAttribute("thresh"));
+                                                                  channelIndex,
+                                                                  channelNode->getDoubleAttribute("thresh"));
 
                             spikeDisplay->setRangeForWaveAxis(plotIndex,
-                                    channelIndex, 
-                                    channelNode->getDoubleAttribute("range"));
+                                                              channelIndex,
+                                                              channelNode->getDoubleAttribute("range"));
 
                         }
-                   }
+                    }
 
 
                 }
@@ -265,7 +267,7 @@ void SpikeDisplayCanvas::loadVisualizerParameters(XmlElement* xml)
 // ----------------------------------------------------------------
 
 SpikeDisplay::SpikeDisplay(SpikeDisplayCanvas* sdc, Viewport* v) :
-	canvas(sdc), viewport(v), thresholdCoordinator(nullptr), shouldInvert(false)
+    canvas(sdc), viewport(v), thresholdCoordinator(nullptr), shouldInvert(false)
 {
 
     totalHeight = 1000;
@@ -305,10 +307,10 @@ SpikePlot* SpikeDisplay::addSpikePlot(int numChannels, int electrodeNum, String
     spikePlots.add(spikePlot);
     addAndMakeVisible(spikePlot);
     spikePlot->invertSpikes(shouldInvert);
-	if (thresholdCoordinator)
-	{
-		spikePlot->registerThresholdCoordinator(thresholdCoordinator);
-	}
+    if (thresholdCoordinator)
+    {
+        spikePlot->registerThresholdCoordinator(thresholdCoordinator);
+    }
 
     return spikePlot;
 }
@@ -453,13 +455,13 @@ void SpikeDisplay::plotSpike(const SpikeObject& spike, int electrodeNum)
     spikePlots[electrodeNum]->processSpikeObject(spike);
 }
 
-void SpikeDisplay::registerThresholdCoordinator(SpikeThresholdCoordinator *stc)
+void SpikeDisplay::registerThresholdCoordinator(SpikeThresholdCoordinator* stc)
 {
-	thresholdCoordinator = stc;
-	for (int i=0; i < spikePlots.size(); i++)
-	{
-		spikePlots[i]->registerThresholdCoordinator(stc);
-	}
+    thresholdCoordinator = stc;
+    for (int i=0; i < spikePlots.size(); i++)
+    {
+        spikePlots[i]->registerThresholdCoordinator(stc);
+    }
 }
 
 int SpikeDisplay::getNumPlots()
@@ -496,7 +498,7 @@ void SpikeDisplay::setRangeForWaveAxis(int plotNum, int axisNum, float range)
 
 SpikePlot::SpikePlot(SpikeDisplayCanvas* sdc, int elecNum, int p, String name_) :
     canvas(sdc), isSelected(false), electrodeNumber(elecNum),  plotType(p),
-	limitsChanged(true), name(name_)
+    limitsChanged(true), name(name_)
 
 {
 
@@ -557,15 +559,15 @@ SpikePlot::SpikePlot(SpikeDisplayCanvas* sdc, int elecNum, int p, String name_)
 
 SpikePlot::~SpikePlot()
 {
-	if (thresholdCoordinator)
-	{
-		thresholdCoordinator->unregisterSpikePlot(this);
-	}
+    if (thresholdCoordinator)
+    {
+        thresholdCoordinator->unregisterSpikePlot(this);
+    }
 }
 
 void SpikePlot::paint(Graphics& g)
 {
-    
+
     //const MessageManagerLock mmLock;
 
     g.setColour(Colours::white);
@@ -574,12 +576,12 @@ void SpikePlot::paint(Graphics& g)
     g.setFont(font);
 
     g.drawText(name,10,0,200,20,Justification::left,false);
-    
+
 }
 
 void SpikePlot::processSpikeObject(const SpikeObject& s)
 {
-   // std::cout << "ElectrodePlot::processSpikeObject()" << std::endl;
+    // std::cout << "ElectrodePlot::processSpikeObject()" << std::endl;
 
     // first, check if it's above threshold
     // bool aboveThreshold = false;
@@ -591,11 +593,11 @@ void SpikePlot::processSpikeObject(const SpikeObject& s)
 
     // if (aboveThreshold)
     // {
-        for (int i = 0; i < nWaveAx; i++)
-            wAxes[i]->updateSpikeData(s);
+    for (int i = 0; i < nWaveAx; i++)
+        wAxes[i]->updateSpikeData(s);
 
-        for (int i = 0; i < nProjAx; i++)
-            pAxes[i]->updateSpikeData(s);
+    for (int i = 0; i < nProjAx; i++)
+        pAxes[i]->updateSpikeData(s);
     // }
 
     //     if (aboveThreshold && isRecording)
@@ -783,7 +785,7 @@ float SpikePlot::getDisplayThresholdForChannel(int i)
 
 void SpikePlot::setDisplayThresholdForChannel(int i, float thresh)
 {
-    std::cout << "Setting threshold to " << thresh << std::endl; 
+    std::cout << "Setting threshold to " << thresh << std::endl;
     wAxes[i]->setDisplayThreshold(thresh);
 }
 
@@ -794,55 +796,55 @@ float SpikePlot::getRangeForChannel(int i)
 
 void SpikePlot::setRangeForChannel(int i, float range)
 {
-    std::cout << "Setting range to " << range << std::endl; 
+    std::cout << "Setting range to " << range << std::endl;
     wAxes[i]->setRange(range);
     rangeButtons[i]->setLabel(String(int(range)));
 }
 
 void SpikePlot::setDetectorThresholdForChannel(int i, float t)
 {
-   // std::cout << "Setting threshold to " << t << std::endl;
+    // std::cout << "Setting threshold to " << t << std::endl;
     wAxes[i]->setDetectorThreshold(t);
 }
 
-void SpikePlot::registerThresholdCoordinator(SpikeThresholdCoordinator *stc)
+void SpikePlot::registerThresholdCoordinator(SpikeThresholdCoordinator* stc)
 {
-	thresholdCoordinator = stc;
-	stc->registerSpikePlot(this);
-	for (int i=0; i < wAxes.size(); i++)
-	{
-		wAxes[i]->registerThresholdCoordinator(stc);
-	}
+    thresholdCoordinator = stc;
+    stc->registerSpikePlot(this);
+    for (int i=0; i < wAxes.size(); i++)
+    {
+        wAxes[i]->registerThresholdCoordinator(stc);
+    }
 }
 
 void SpikePlot::setAllThresholds(float displayThreshold, float range)
 {
-	String label;
-	for (int i=0; i< nWaveAx; i++)
-	{
-		ranges.set(i,range);
-		wAxes[i]->setDisplayThreshold(displayThreshold);
-	}
-	
-	if (range == 100)
-	{
-		label = "100";
-	}
-	else if (range == 250)
-	{
-		label = "250";
-	}
-	else
-	{
-		label = "500";
-	}
-	
-	for(int i=0; i < rangeButtons.size(); i++)
-	{
-		rangeButtons[i]->setLabel(label);
-	}
-
-	setLimitsOnAxes();
+    String label;
+    for (int i=0; i< nWaveAx; i++)
+    {
+        ranges.set(i,range);
+        wAxes[i]->setDisplayThreshold(displayThreshold);
+    }
+
+    if (range == 100)
+    {
+        label = "100";
+    }
+    else if (range == 250)
+    {
+        label = "250";
+    }
+    else
+    {
+        label = "500";
+    }
+
+    for (int i=0; i < rangeButtons.size(); i++)
+    {
+        rangeButtons[i]->setLabel(label);
+    }
+
+    setLimitsOnAxes();
 }
 
 void SpikePlot::invertSpikes(bool shouldInvert)
@@ -857,8 +859,8 @@ void SpikePlot::invertSpikes(bool shouldInvert)
 
 
 WaveAxes::WaveAxes(int channel) : GenericAxes(channel),
-    drawGrid(true), 
-    displayThresholdLevel(0.0f),  
+    drawGrid(true),
+    displayThresholdLevel(0.0f),
     detectorThresholdLevel(0.0f),
     spikesReceivedSinceLastRedraw(0),
     spikeIndex(0),
@@ -866,9 +868,9 @@ WaveAxes::WaveAxes(int channel) : GenericAxes(channel),
     range(250.0f),
     isOverThresholdSlider(false),
     isDraggingThresholdSlider(false),
-	thresholdCoordinator(nullptr),
+    thresholdCoordinator(nullptr),
     spikesInverted(false)
-    
+
 {
 
     addMouseListener(this, true);
@@ -901,7 +903,7 @@ void WaveAxes::paint(Graphics& g)
     g.setColour(Colours::black);
     g.fillRect(0,0,getWidth(), getHeight());
 
-   // int chan = 0;
+    // int chan = 0;
 
     // draw the grid lines for the waveforms
 
@@ -919,16 +921,16 @@ void WaveAxes::paint(Graphics& g)
     }
 
 
-     for (int spikeNum = 0; spikeNum < bufferSize; spikeNum++)
-     {
+    for (int spikeNum = 0; spikeNum < bufferSize; spikeNum++)
+    {
 
-         if (spikeNum != spikeIndex)
-         {
-             g.setColour(Colours::grey);
-             plotSpike(spikeBuffer[spikeNum], g);
-         }
+        if (spikeNum != spikeIndex)
+        {
+            g.setColour(Colours::grey);
+            plotSpike(spikeBuffer[spikeNum], g);
+        }
 
-     }
+    }
 
     g.setColour(Colours::white);
     plotSpike(spikeBuffer[spikeIndex], g);
@@ -960,17 +962,19 @@ void WaveAxes::plotSpike(const SpikeObject& s, Graphics& g)
 
         if (*s.gain != 0)
         {
-            
+
             float s1, s2;
 
             if (spikesInverted)
             {
                 s1 = h/2 + float(s.data[sampIdx]-32768)/float(*s.gain)*1000.0f / range * h;
                 s2 = h/2 + float(s.data[sampIdx+1]-32768)/float(*s.gain)*1000.0f / range * h;
-            } else {
+            }
+            else
+            {
                 s1 = h/2 - float(s.data[sampIdx]-32768)/float(*s.gain)*1000.0f / range * h;
                 s2 = h/2 - float(s.data[sampIdx+1]-32768)/float(*s.gain)*1000.0f / range * h;
-     
+
             }
             g.drawLine(x,
                        s1,
@@ -1003,11 +1007,11 @@ void WaveAxes::drawThresholdSlider(Graphics& g)
     g.drawText(String(roundFloatToInt(displayThresholdLevel)),2,h,25,10,Justification::left, false);
 
     // draw detector threshold (not editable)
-     if (spikesInverted)
+    if (spikesInverted)
         h = getHeight()*(0.5f - detectorThresholdLevel/range);
     else
         h = getHeight()*(0.5f + detectorThresholdLevel/range);
-    
+
     g.setColour(Colours::orange);
     g.drawLine(0, h, getWidth(), h);
 }
@@ -1048,7 +1052,7 @@ bool WaveAxes::updateSpikeData(const SpikeObject& s)
         spikeBuffer.set(spikeIndex, newSpike);
 
         spikesReceivedSinceLastRedraw++;
-        
+
     }
 
     return true;
@@ -1150,7 +1154,7 @@ void WaveAxes::mouseDrag(const MouseEvent& event)
 
         float thresholdSliderPosition =  float(event.y) / float(getHeight());
 
-         if (spikesInverted)
+        if (spikesInverted)
         {
             if (thresholdSliderPosition > 0.5f)
                 thresholdSliderPosition = 0.5f;
@@ -1158,7 +1162,9 @@ void WaveAxes::mouseDrag(const MouseEvent& event)
                 thresholdSliderPosition = 0.0f;
 
             displayThresholdLevel = (0.5f - thresholdSliderPosition) * range;
-        } else {
+        }
+        else
+        {
             if (thresholdSliderPosition < 0.5f)
                 thresholdSliderPosition = 0.5f;
             else if (thresholdSliderPosition > 1.0f)
@@ -1169,12 +1175,12 @@ void WaveAxes::mouseDrag(const MouseEvent& event)
 
         //std::cout << "Threshold = " << thresholdLevel << std::endl;
 
-		if (thresholdCoordinator)
-		{
-			thresholdCoordinator->thresholdChanged(displayThresholdLevel,range);
-		}
+        if (thresholdCoordinator)
+        {
+            thresholdCoordinator->thresholdChanged(displayThresholdLevel,range);
+        }
 
-		repaint();
+        repaint();
     }
 }
 
@@ -1205,16 +1211,16 @@ void WaveAxes::setDetectorThreshold(float t)
     detectorThresholdLevel = t;
 }
 
-void WaveAxes::registerThresholdCoordinator(SpikeThresholdCoordinator *stc)
+void WaveAxes::registerThresholdCoordinator(SpikeThresholdCoordinator* stc)
 {
-	thresholdCoordinator = stc;
+    thresholdCoordinator = stc;
 }
 
 void WaveAxes::setDisplayThreshold(float threshold)
 {
-	displayThresholdLevel = threshold;
-	
-	repaint();
+    displayThresholdLevel = threshold;
+
+    repaint();
 }
 
 // --------------------------------------------------
@@ -1481,36 +1487,36 @@ SpikeThresholdCoordinator::SpikeThresholdCoordinator() : lockThresholds(false) {
 
 SpikeThresholdCoordinator::~SpikeThresholdCoordinator()
 {
-	masterReference.clear();
+    masterReference.clear();
 }
 
-void SpikeThresholdCoordinator::registerSpikePlot(SpikePlot *sp)
+void SpikeThresholdCoordinator::registerSpikePlot(SpikePlot* sp)
 {
-	registeredPlots.addIfNotAlreadyThere(sp);
+    registeredPlots.addIfNotAlreadyThere(sp);
 }
 
-void SpikeThresholdCoordinator::unregisterSpikePlot(SpikePlot *sp)
+void SpikeThresholdCoordinator::unregisterSpikePlot(SpikePlot* sp)
 {
-	registeredPlots.removeAllInstancesOf(sp);
+    registeredPlots.removeAllInstancesOf(sp);
 }
 
 void SpikeThresholdCoordinator::setLockThresholds(bool en)
 {
-	lockThresholds = en;
+    lockThresholds = en;
 }
 
 bool SpikeThresholdCoordinator::getLockThresholds()
 {
-	return lockThresholds;
+    return lockThresholds;
 }
 
 void SpikeThresholdCoordinator::thresholdChanged(float displayThreshold, float range)
 {
-	if (lockThresholds)
-	{
-		for (int i = 0; i < registeredPlots.size(); i++)
-		{
-			registeredPlots[i]->setAllThresholds(displayThreshold,range);
-		}
-	}
+    if (lockThresholds)
+    {
+        for (int i = 0; i < registeredPlots.size(); i++)
+        {
+            registeredPlots[i]->setAllThresholds(displayThreshold,range);
+        }
+    }
 }
\ No newline at end of file
diff --git a/Source/Processors/Visualization/SpikeDisplayCanvas.h b/Source/Processors/Visualization/SpikeDisplayCanvas.h
index aeaad79fd27ad3aa69668bbe20d2cd593ea0c52b..2a1f6e33a1991b667e307e1f69bac0a4fce725b9 100755
--- a/Source/Processors/Visualization/SpikeDisplayCanvas.h
+++ b/Source/Processors/Visualization/SpikeDisplayCanvas.h
@@ -99,7 +99,7 @@ public:
 
     void startRecording() { } // unused
     void stopRecording() { } // unused
-    
+
     SpikeDisplayNode* processor;
 
     void saveVisualizerParameters(XmlElement* xml);
@@ -118,8 +118,8 @@ private:
 
     int scrollBarThickness;
 
-	ScopedPointer<SpikeThresholdCoordinator> thresholdCoordinator;
-	ScopedPointer<UtilityButton> lockThresholdsButton;
+    ScopedPointer<SpikeThresholdCoordinator> thresholdCoordinator;
+    ScopedPointer<UtilityButton> lockThresholdsButton;
     ScopedPointer<UtilityButton> invertSpikesButton;
 
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SpikeDisplayCanvas);
@@ -160,7 +160,7 @@ public:
     void setThresholdForWaveAxis(int plotNum, int axisNum, float threshold);
     void setRangeForWaveAxis(int plotNum, int axisNum, float range);
 
-	void registerThresholdCoordinator(SpikeThresholdCoordinator *stc);
+    void registerThresholdCoordinator(SpikeThresholdCoordinator* stc);
 
 private:
 
@@ -182,7 +182,7 @@ private:
     // float tetrodePlotMinWidth, stereotrodePlotMinWidth, singleElectrodePlotMinWidth;
     // float tetrodePlotRatio, stereotrodePlotRatio, singleElectrodePlotRatio;
 
-	SpikeThresholdCoordinator *thresholdCoordinator;
+    SpikeThresholdCoordinator* thresholdCoordinator;
 
 };
 
@@ -221,7 +221,7 @@ public:
 
     void clear();
 
-     void invertSpikes(bool);
+    void invertSpikes(bool);
 
     float minWidth;
     float aspectRatio;
@@ -235,9 +235,9 @@ public:
     float getRangeForChannel(int);
     void setRangeForChannel(int axisNum, float range);
 
-	//For locking the tresholds
-	void registerThresholdCoordinator(SpikeThresholdCoordinator *stc);
-	void setAllThresholds(float displayThreshold, float range);
+    //For locking the tresholds
+    void registerThresholdCoordinator(SpikeThresholdCoordinator* stc);
+    void setAllThresholds(float displayThreshold, float range);
 
 private:
 
@@ -262,7 +262,7 @@ private:
 
     Font font;
 
-	WeakReference<SpikeThresholdCoordinator> thresholdCoordinator;
+    WeakReference<SpikeThresholdCoordinator> thresholdCoordinator;
 
 };
 
@@ -351,9 +351,9 @@ public:
 
     //MouseCursor getMouseCursor();
 
-	//For locking the thresholds
-	void registerThresholdCoordinator(SpikeThresholdCoordinator *stc);
-	void setDisplayThreshold(float threshold);
+    //For locking the thresholds
+    void registerThresholdCoordinator(SpikeThresholdCoordinator* stc);
+    void setDisplayThreshold(float threshold);
 
     void invertSpikes(bool shouldInvert)
     {
@@ -391,7 +391,7 @@ private:
     bool isDraggingThresholdSlider;
 
     MouseCursor::StandardCursorType cursorType;
-	SpikeThresholdCoordinator *thresholdCoordinator;
+    SpikeThresholdCoordinator* thresholdCoordinator;
 
     bool spikesInverted;
 
@@ -448,23 +448,23 @@ private:
 class SpikeThresholdCoordinator
 {
 public:
-	SpikeThresholdCoordinator();
-	~SpikeThresholdCoordinator();
+    SpikeThresholdCoordinator();
+    ~SpikeThresholdCoordinator();
 
-	void registerSpikePlot(SpikePlot *sp);
-	void unregisterSpikePlot(SpikePlot *sp);
-	void setLockThresholds(bool en);
-	bool getLockThresholds();
+    void registerSpikePlot(SpikePlot* sp);
+    void unregisterSpikePlot(SpikePlot* sp);
+    void setLockThresholds(bool en);
+    bool getLockThresholds();
 
-	void thresholdChanged(float displayThreshold, float range);
+    void thresholdChanged(float displayThreshold, float range);
 
 private:
-	bool lockThresholds;
-	Array<SpikePlot*> registeredPlots;
+    bool lockThresholds;
+    Array<SpikePlot*> registeredPlots;
+
+    WeakReference<SpikeThresholdCoordinator>::Master masterReference;
+    friend class WeakReference<SpikeThresholdCoordinator>;
 
-	WeakReference<SpikeThresholdCoordinator>::Master masterReference;
-	friend class WeakReference<SpikeThresholdCoordinator>;
-	
 };
 
 
diff --git a/Source/Processors/Visualization/SpikeObject.cpp b/Source/Processors/Visualization/SpikeObject.cpp
index c117765702633db4d929b04f2a95cb8a449a9962..f63d2d769326c059472cd03e4694f3c966a1288b 100755
--- a/Source/Processors/Visualization/SpikeObject.cpp
+++ b/Source/Processors/Visualization/SpikeObject.cpp
@@ -86,11 +86,11 @@ bool unpackSpike(SpikeObject* s, const uint8_t* buffer, int bufferSize)
     memcpy(&(s->eventType), buffer+idx, 1);
     idx += 1;
 
-   // if (s->eventType != 4)
-   // {
-   //     std::cout << "received invalid spike -- incorrect event code" << std::endl;
-   //     return false;
-   // }
+    // if (s->eventType != 4)
+    // {
+    //     std::cout << "received invalid spike -- incorrect event code" << std::endl;
+    //     return false;
+    // }
 
     memcpy(&(s->timestamp), buffer+idx, 8);
     idx += 8;
diff --git a/Source/Processors/Visualization/SpikeObject.h b/Source/Processors/Visualization/SpikeObject.h
index b016770710f07bef39ea215eac9d6688197f0117..6c99dc0b5e0094d26bdd789aa689d4ee09866bf0 100755
--- a/Source/Processors/Visualization/SpikeObject.h
+++ b/Source/Processors/Visualization/SpikeObject.h
@@ -33,7 +33,7 @@
 #define CHECK_BUFFER_VALIDITY true
 #define SPIKE_EVENT_CODE 4;
 #define MAX_SPIKE_BUFFER_LEN 512 // max length of spike buffer in bytes
-                                 // the true max calculated from the spike values below is actually 507
+// the true max calculated from the spike values below is actually 507
 
 #define SPIKE_BASE_CODE 100
 
diff --git a/Source/UI/ControlPanel.cpp b/Source/UI/ControlPanel.cpp
index 3a7188cc83f22e5c775ccd8ea24cb77cb525f65c..5034b7d898d4ce13e6aa1bb32ba98e905cb78881 100755
--- a/Source/UI/ControlPanel.cpp
+++ b/Source/UI/ControlPanel.cpp
@@ -97,7 +97,7 @@ CPUMeter::CPUMeter() : Label("CPU Meter","0.0"), cpu(0.0f), lastCpu(0.0f)
     // Typeface::Ptr typeface = new CustomTypeface(mis);
     // font = Font(typeface);
     // font.setHeight(12);
-    
+
     setTooltip("CPU usage");
 }
 
@@ -137,7 +137,7 @@ DiskSpaceMeter::DiskSpaceMeter()
     // Typeface::Ptr typeface = new CustomTypeface(mis);
     // font = Font(typeface);
     // font.setHeight(12);
-    
+
     setTooltip("Disk space available");
 }
 
@@ -193,10 +193,12 @@ void Clock::paint(Graphics& g)
     if (isRecording)
     {
         g.fillAll(Colour(255,0,0));
-    } else {
+    }
+    else
+    {
         g.fillAll(Colour(58,58,58));
     }
-    
+
     drawTime(g);
 }
 
@@ -406,10 +408,10 @@ ControlPanel::ControlPanel(ProcessorGraph* graph_, AudioComponent* audio_)
 
 
     File executable = File::getSpecialLocation(File::currentExecutableFile);
-    
+
 #if defined(__APPLE__)
     const String executableDirectory =
-    executable.getParentDirectory().getParentDirectory().getParentDirectory().getParentDirectory().getFullPathName();
+        executable.getParentDirectory().getParentDirectory().getParentDirectory().getParentDirectory().getFullPathName();
 #else
     const String executableDirectory = executable.getParentDirectory().getFullPathName();
 #endif
@@ -450,7 +452,7 @@ ControlPanel::ControlPanel(ProcessorGraph* graph_, AudioComponent* audio_)
     startTimer(10);
 
     setWantsKeyboardFocus(true);
-    
+
     backgroundColour = Colour(58,58,58);
 
 }
@@ -527,9 +529,11 @@ void ControlPanel::resized()
     if (playButton != 0)
     {
         if (w > 330)
-            playButton->setBounds(w-h*10,5,h-5,h-10);\
+            playButton->setBounds(w-h*10,5,h-5,h-10);
+        \
         else
-            playButton->setBounds(5,5,h-5,h-10);\
+            playButton->setBounds(5,5,h-5,h-10);
+        \
     }
 
     if (recordButton != 0)
@@ -582,12 +586,12 @@ void ControlPanel::resized()
     {
         if (getWidth() < 750 && getWidth() >= 570)
             audioEditor->setBounds(w-526,0,h*8,h);
-       else if (getWidth() < 570)
+        else if (getWidth() < 570)
             audioEditor->setBounds(8,0+offset2,h*8,h);
         else
             audioEditor->setBounds(h*7,0,h*8,h);
     }
-        
+
 
     if (cpb != 0)
     {
@@ -660,7 +664,7 @@ void ControlPanel::startRecording()
     appendText->setEditable(false);
     dateText->setColour(Label::textColourId, Colours::black);
 
-    graph->setRecordState(true); 
+    graph->setRecordState(true);
 
     repaint();
 }
@@ -684,7 +688,7 @@ void ControlPanel::stopRecording()
 void ControlPanel::buttonClicked(Button* button)
 
 {
-    
+
     if (button == newDirectoryButton && newDirectoryButton->getEnabledState())
     {
         graph->getRecordNode()->newDirectoryNeeded = true;
@@ -707,12 +711,14 @@ void ControlPanel::buttonClicked(Button* button)
                 audio->beginCallbacks();
                 masterClock->start();
                 audioEditor->disable();
-                
+
                 stopTimer();
                 startTimer(250); // refresh every 250 ms
 
             }
-        } else {
+        }
+        else
+        {
 
             if (recordButton->getToggleState())
             {
@@ -726,7 +732,7 @@ void ControlPanel::buttonClicked(Button* button)
             stopTimer();
             startTimer(60000); // back to refresh every minute
             audioEditor->enable();
-            
+
         }
 
         return;
@@ -739,13 +745,15 @@ void ControlPanel::buttonClicked(Button* button)
             if (playButton->getToggleState())
             {
                 startRecording();
-            } else {
+            }
+            else
+            {
                 if (graph->enableProcessors()) // start the processor graph
                 {
                     audio->beginCallbacks();
                     masterClock->start();
                     audioEditor->disable();
-                    
+
                     stopTimer();
                     startTimer(250); // refresh every 250 ms
 
@@ -755,10 +763,12 @@ void ControlPanel::buttonClicked(Button* button)
 
                 }
             }
-        } else {
+        }
+        else
+        {
             stopRecording();
         }
-    }     
+    }
 
 }
 
@@ -806,7 +816,7 @@ void ControlPanel::disableCallbacks()
 void ControlPanel::timerCallback()
 {
     //std::cout << "Message Received." << std::endl;
-   refreshMeters();
+    refreshMeters();
 
 }
 
diff --git a/Source/UI/ControlPanel.h b/Source/UI/ControlPanel.h
index 86f24bf221ac0e7a352970a33678cd68d01cb618..2e623282d7742f1a6255c25fedc2f4fa58c3ec5f 100755
--- a/Source/UI/ControlPanel.h
+++ b/Source/UI/ControlPanel.h
@@ -239,8 +239,8 @@ public:
 
     /** Sets the open/closed state of the ControlPanelButton.*/
     void setState(bool);
-    
-   
+
+
 
     /** Draws the button. */
     void paint(Graphics& g);
@@ -253,7 +253,7 @@ private:
     ControlPanel* cp;
 
     bool open;
-    
+
 
 };
 
@@ -326,12 +326,12 @@ public:
 
     /** Load settings. */
     void loadStateFromXml(XmlElement*);
-    
-	void handleIncomdingMessages();
 
-		/** Informs the Control Panel that recording has begun.*/
+    void handleIncomdingMessages();
+
+    /** Informs the Control Panel that recording has begun.*/
     void startRecording();
-    
+
     /** Informs the Control Panel that recording has stopped.*/
     void stopRecording();
 
@@ -341,10 +341,10 @@ public:
     /** Sets the list of recently used directories for saving data. */
     void setRecentlyUsedFilenames(const StringArray& filenames);
 
-	ScopedPointer<RecordButton> recordButton;
+    ScopedPointer<RecordButton> recordButton;
 private:
     ScopedPointer<PlayButton> playButton;
-    
+
     ScopedPointer<Clock> masterClock;
     ScopedPointer<CPUMeter> cpuMeter;
     ScopedPointer<DiskSpaceMeter> diskMeter;
@@ -388,7 +388,7 @@ private:
 
     /** Draws the boundaries around the FilenameComponent.*/
     void createPaths();
-    
+
     Colour backgroundColour;
 
 };
diff --git a/Source/UI/CustomArrowButton.cpp b/Source/UI/CustomArrowButton.cpp
index 60c4c2d69c64090683222082426aa27a31b797fb..5081a341258454eb3ed209e0bbf9685e8427f184 100644
--- a/Source/UI/CustomArrowButton.cpp
+++ b/Source/UI/CustomArrowButton.cpp
@@ -1,56 +1,56 @@
 /*
  ------------------------------------------------------------------
- 
+
  This file is part of the Open Ephys GUI
  Copyright (C) 2014 Florian Franzen
- 
+
  ------------------------------------------------------------------
- 
+
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
- 
+
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
- 
+
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- 
+
  */
 
 #include "CustomArrowButton.h"
 
 
-CustomArrowButton::CustomArrowButton (const String& name, float direction)
-   : Button (name)
+CustomArrowButton::CustomArrowButton(const String& name, float direction)
+    : Button(name)
 {
-    path.addTriangle (0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.5f);
-    path.applyTransform (AffineTransform::rotation (float_Pi * 2.0f * direction, 0.5f, 0.5f));
+    path.addTriangle(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.5f);
+    path.applyTransform(AffineTransform::rotation(float_Pi * 2.0f * direction, 0.5f, 0.5f));
 }
 
 CustomArrowButton::~CustomArrowButton() {}
 
-void CustomArrowButton::paintButton (Graphics& g, bool /*isMouseOverButton*/, bool isButtonDown)
+void CustomArrowButton::paintButton(Graphics& g, bool /*isMouseOverButton*/, bool isButtonDown)
 {
-    
+
     const float borderWidth = isEnabled() ? (isButtonDown ? 1.2f : 0.5f) : 0.3f;
-    
+
     juce::LookAndFeel_V1::drawGlassLozenge(g,
-                     borderWidth, borderWidth,
-                     getWidth() - borderWidth * 2.0f, getHeight() - borderWidth * 2.0f,
-                     Colours::orange, borderWidth, -1.0f,
-                     true, true, true, true);
-    
+                                           borderWidth, borderWidth,
+                                           getWidth() - borderWidth * 2.0f, getHeight() - borderWidth * 2.0f,
+                                           Colours::orange, borderWidth, -1.0f,
+                                           true, true, true, true);
+
     if (isEnabled())
     {
-        Path p (path);
-        p.scaleToFit (getWidth() * 0.25f, getHeight() * 0.25f,
-                      getWidth() * 0.5f, getHeight() * 0.5f, false);
-        
-        g.setColour (Colours::darkgrey);
-        g.fillPath (p);
+        Path p(path);
+        p.scaleToFit(getWidth() * 0.25f, getHeight() * 0.25f,
+                     getWidth() * 0.5f, getHeight() * 0.5f, false);
+
+        g.setColour(Colours::darkgrey);
+        g.fillPath(p);
     }
 }
\ No newline at end of file
diff --git a/Source/UI/CustomArrowButton.h b/Source/UI/CustomArrowButton.h
index 95fcbed6b20c5c5e54f26e57f54714570cb1ed7c..ea80a6e5b8356e1a1f8ed0fb1570770a3792a449 100644
--- a/Source/UI/CustomArrowButton.h
+++ b/Source/UI/CustomArrowButton.h
@@ -1,24 +1,24 @@
 /*
  ------------------------------------------------------------------
- 
+
  This file is part of the Open Ephys GUI
  Copyright (C) 2014 Florian Franzen
- 
+
  ------------------------------------------------------------------
- 
+
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
- 
+
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
- 
+
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- 
+
  */
 
 #ifndef __CUSTOMARROWBUTTON__
@@ -28,29 +28,29 @@
 
 /**
  Customized version of the ArrowButton with an added OpenEphys LookAndFeel.
- 
+
  @see ArrowButton
  */
 class CustomArrowButton  : public Button
 {
 public:
     /** Creates an CustomArrowButton.
-     
+
      @param name        the name to give the button
      @param direction   the direction the arrow should points to (0.0 = right, 0.25 = down, 0.5 = left and 0.75 = up)
      */
-    CustomArrowButton (const String& name, float direction);
+    CustomArrowButton(const String& name, float direction);
 
     /** Destructor. */
     ~CustomArrowButton();
 
     /** @internal */
-    void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown);
+    void paintButton(Graphics&, bool isMouseOverButton, bool isButtonDown);
 
 private:
     Path path;
 
-    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CustomArrowButton)
+    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CustomArrowButton)
 };
 
 
diff --git a/Source/UI/CustomLookAndFeel.cpp b/Source/UI/CustomLookAndFeel.cpp
index 75848e0a7e27aa9013ac15bc2d46f37309beba15..d193f87a9d1dcf2840093fd8411aa3236c8352ff 100755
--- a/Source/UI/CustomLookAndFeel.cpp
+++ b/Source/UI/CustomLookAndFeel.cpp
@@ -442,7 +442,7 @@ void CustomLookAndFeel::drawGlassPointer(Graphics& g,
     g.strokePath(p, PathStrokeType(outlineThickness));
 }
 
-Button* CustomLookAndFeel::createSliderButton(Slider &s, bool isIncrement)
+Button* CustomLookAndFeel::createSliderButton(Slider& s, bool isIncrement)
 {
     return new CustomArrowButton(String::empty, isIncrement ? 0 : 0.5);
 }
@@ -479,10 +479,10 @@ void CustomLookAndFeel::drawComboBox(Graphics& g, int width, int height,
                                 .withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.5f));*/
 
     juce::LookAndFeel_V1::drawGlassLozenge(g,
-                     buttonX + outlineThickness, buttonY + outlineThickness,
-                     buttonW - outlineThickness * 2.0f, buttonH - outlineThickness * 2.0f,
-                     baseColour, outlineThickness, -1.0f,
-                     true, true, true, true);
+                                           buttonX + outlineThickness, buttonY + outlineThickness,
+                                           buttonW - outlineThickness * 2.0f, buttonH - outlineThickness * 2.0f,
+                                           baseColour, outlineThickness, -1.0f,
+                                           true, true, true, true);
 
     if (box.isEnabled())
     {
diff --git a/Source/UI/CustomLookAndFeel.h b/Source/UI/CustomLookAndFeel.h
index 79e78994c702e07e744d7de0e2ebca6ccee6308a..e6107fe01982f0d6f5a1a74e8f753f272d445cd5 100755
--- a/Source/UI/CustomLookAndFeel.h
+++ b/Source/UI/CustomLookAndFeel.h
@@ -101,8 +101,8 @@ public:
                           const float diameter,
                           const Colour& colour, const float outlineThickness,
                           const int direction) throw();
-    
-    Button* createSliderButton(Slider &s, bool	isIncrement);
+
+    Button* createSliderButton(Slider& s, bool	isIncrement);
 
     // ======== custom combo box methods: =============================
 
diff --git a/Source/UI/DataViewport.cpp b/Source/UI/DataViewport.cpp
index a0ec80c1ce7fb5d4cf2fdb0edca1b8e8608663ac..d0b0331af8a8d690dfe8f3c74b64c63e1a693d02 100755
--- a/Source/UI/DataViewport.cpp
+++ b/Source/UI/DataViewport.cpp
@@ -74,7 +74,7 @@ int DataViewport::addTabToDataViewport(String name, Component* component, Generi
 
     editorArray.add(editor);
 
-  //  std::cout << "Adding tab with index " << tabIndex << std::endl;
+    //  std::cout << "Adding tab with index " << tabIndex << std::endl;
 
     setCurrentTabIndex(tabArray.size()-1);
 
diff --git a/Source/UI/EditorViewport.cpp b/Source/UI/EditorViewport.cpp
index 3534ae5db3eb71caebc381e39c84db8977b5688b..e7d0ecfba23f6deac4a5285d0dabe7e00255998d 100755
--- a/Source/UI/EditorViewport.cpp
+++ b/Source/UI/EditorViewport.cpp
@@ -146,10 +146,10 @@ void EditorViewport::paint(Graphics& g)
 
     //if (editorArray.size() > 0)
     //{
-        //if (!editorArray[0]->getProcessor()->isSource())
+    //if (!editorArray[0]->getProcessor()->isSource())
     //    g.drawImageAt(sourceDropImage, x, y);
     //} else {
-        g.drawImageAt(sourceDropImage, x, y);
+    g.drawImageAt(sourceDropImage, x, y);
     //}
 }
 
@@ -159,10 +159,10 @@ bool EditorViewport::isInterestedInDragSource(const SourceDetails& dragSourceDet
     {
         return false;
     }
-	else if (dragSourceDetails.description.toString().startsWith("EditorDrag"))
-	{
-		return false;
-	}
+    else if (dragSourceDetails.description.toString().startsWith("EditorDrag"))
+    {
+        return false;
+    }
     else
     {
         return true;
@@ -272,7 +272,7 @@ void EditorViewport::itemDropped(const SourceDetails& dragSourceDetails)
         refreshEditors();
 
         somethingIsBeingDraggedOver = false;
-        
+
         getGraphViewer()->addNode(activeEditor);
 
         repaint();
@@ -350,7 +350,7 @@ void EditorViewport::deleteNode(GenericEditor* editor)
 
         signalChainManager->updateVisibleEditors(editor, indexOfMovingComponent, insertionPoint, REMOVE);
         getGraphViewer()->removeNode(editor);
-        
+
         refreshEditors();
 
         getProcessorGraph()->removeProcessor((GenericProcessor*) editor->getProcessor());
@@ -359,8 +359,8 @@ void EditorViewport::deleteNode(GenericEditor* editor)
         indexOfMovingComponent = -1;
 
         somethingIsBeingDraggedOver = false;
-        
-        
+
+
 
         repaint();
 
@@ -694,7 +694,7 @@ void EditorViewport::mouseDown(const MouseEvent& e)
     {
 
         if (e.eventComponent == editorArray[i])
-           
+
             // || e.eventComponent->getParentComponent() == editorArray[i] ||
             //    e.eventComponent->getParentComponent()->getParentComponent() ==
             //            editorArray[i])
@@ -705,7 +705,9 @@ void EditorViewport::mouseDown(const MouseEvent& e)
                 if (editorArray[i]->getCollapsedState())
                 {
                     editorArray[i]->switchCollapsedState();
-                } else {
+                }
+                else
+                {
                     if (e.y < 22)
                     {
                         editorArray[i]->switchCollapsedState();
@@ -718,7 +720,7 @@ void EditorViewport::mouseDown(const MouseEvent& e)
             {
 
                 if (!editorArray[i]->getCollapsedState() && e.y > 22)
-                     return;
+                    return;
 
                 if (editorArray[i]->isMerger() || editorArray[i]->isSplitter())
                     return;
@@ -726,8 +728,8 @@ void EditorViewport::mouseDown(const MouseEvent& e)
                 PopupMenu m;
 
                 if (editorArray[i]->getCollapsedState())
-                     m.addItem(3, "Uncollapse", true);
-                 else
+                    m.addItem(3, "Uncollapse", true);
+                else
                     m.addItem(3, "Collapse", true);
 
                 if (canEdit)
@@ -742,22 +744,24 @@ void EditorViewport::mouseDown(const MouseEvent& e)
                 if (result == 1)
                 {
                     editorNamingLabel.setText("", dontSendNotification);
-                    
+
                     juce::Rectangle<int> rect1 = juce::Rectangle<int>(editorArray[i]->getScreenX()+20,editorArray[i]->getScreenY()+11,1,1);
 
                     CallOutBox callOut(editorNamingLabel, rect1, nullptr);
                     editorToUpdate = editorArray[i];
                     callOut.runModalLoop();
-                   // editorNamingLabel.showEditor();
+                    // editorNamingLabel.showEditor();
                     //CallOutBox& myBox = CallOutBox::launchAsynchronously(&editorNamingLabel, rect1, nullptr);
-                    
+
                     return;
 
-                } else if (result == 2)
+                }
+                else if (result == 2)
                 {
                     deleteNode(editorArray[i]);
                     return;
-                } else if (result == 3)
+                }
+                else if (result == 3)
                 {
                     editorArray[i]->switchCollapsedState();
                     refreshEditors();
@@ -1239,7 +1243,7 @@ const String EditorViewport::saveState(File fileToUse)
     int saveOrder = 0;
 
     XmlElement* xml = new XmlElement("SETTINGS");
-	
+
     XmlElement* info = xml->createNewChildElement("INFO");
 
     XmlElement* version = info->createNewChildElement("VERSION");
@@ -1403,7 +1407,7 @@ const String EditorViewport::loadState(File fileToLoad)
     // {
     //     return "No configuration selected.";
     // }
-	int maxID = 100;
+    int maxID = 100;
     currentFile = fileToLoad;
 
     std::cout << "Loading processor graph." << std::endl;
@@ -1420,30 +1424,30 @@ const String EditorViewport::loadState(File fileToLoad)
         return "Not a valid file.";
     }
 
-	bool sameVersion = false;
+    bool sameVersion = false;
     String versionString;
 
-	forEachXmlChildElement(*xml, element)
+    forEachXmlChildElement(*xml, element)
+    {
+        if (element->hasTagName("INFO"))
+        {
+            forEachXmlChildElement(*element, element2)
+            {
+                if (element2->hasTagName("VERSION"))
+                {
+                    versionString = element2->getAllSubText();
+                    // float majorVersion = versionString.upToFirstOccurrenceOf(".", false, true).getIntValue();
+                    //             float minorVersion = versionString.fromFirstOccurrenceOf(".", false, true).getFloatValue();
+
+                    if (versionString.equalsIgnoreCase(JUCEApplication::getInstance()->getApplicationVersion()))
+                        sameVersion = true;
+                }
+            }
+            break;
+        }
+    }
+    if (!sameVersion)
     {
-		  if (element->hasTagName("INFO"))
-		  {
-			  forEachXmlChildElement(*element, element2)
-			  {
-			   if (element2->hasTagName("VERSION")) 
-			   {
-				   versionString = element2->getAllSubText();
-				   // float majorVersion = versionString.upToFirstOccurrenceOf(".", false, true).getIntValue();
-       //             float minorVersion = versionString.fromFirstOccurrenceOf(".", false, true).getFloatValue();
-
-				   if (versionString.equalsIgnoreCase(JUCEApplication::getInstance()->getApplicationVersion()))
-					   sameVersion = true;
-			   }
-			  }
-			  break;
-		  }
-	}
-	if (!sameVersion)
-	{
         String responseString = "Your configuration file was saved from a different version of the GUI than the one you're using. \n";
         responseString += "The current software is version ";
         responseString += JUCEApplication::getInstance()->getApplicationVersion();
@@ -1452,19 +1456,21 @@ const String EditorViewport::loadState(File fileToLoad)
         {
             responseString += " is version ";
             responseString += versionString;
-        } else {
+        }
+        else
+        {
             responseString += "does not have a version number";
         }
-        
+
         responseString += ".\n This file may not load properly. Continue?";
 
-		bool response = AlertWindow::showOkCancelBox (AlertWindow::NoIcon, 
-                                     "Version mismatch", responseString,
-                                     "Yes", "No", 0, 0);
+        bool response = AlertWindow::showOkCancelBox(AlertWindow::NoIcon,
+                                                     "Version mismatch", responseString,
+                                                     "Yes", "No", 0, 0);
         if (!response)
-			return "Failed To Open " + fileToLoad.getFileName();
-  
-	}
+            return "Failed To Open " + fileToLoad.getFileName();
+
+    }
     clearSignalChain();
 
     String description;// = " ";
@@ -1478,88 +1484,89 @@ const String EditorViewport::loadState(File fileToLoad)
         if (element->hasTagName("SIGNALCHAIN"))
         {
 
-        forEachXmlChildElement(*element, processor)
-        {
-
-            if (processor->hasTagName("PROCESSOR"))
+            forEachXmlChildElement(*element, processor)
             {
 
-                int insertionPt = processor->getIntAttribute("insertionPoint");
-                currentId = processor->getIntAttribute("NodeId");
-
-				maxID= (maxID > currentId) ? maxID  : currentId ;
-
-                if (insertionPt == 1)
-                {
-                    insertionPoint = editorArray.size();
-                }
-                else
+                if (processor->hasTagName("PROCESSOR"))
                 {
-                    insertionPoint = 0;
-                }
 
-                //Point<int> pt =
-                SourceDetails sd = SourceDetails(processor->getStringAttribute("name"),
-                                                 0,
-                                                 Point<int>(0,0));
+                    int insertionPt = processor->getIntAttribute("insertionPoint");
+                    currentId = processor->getIntAttribute("NodeId");
 
-                itemDropped(sd);
+                    maxID= (maxID > currentId) ? maxID  : currentId ;
 
-                p = (GenericProcessor*) lastEditor->getProcessor();
-                p->loadOrder = loadOrder;
-                p->parametersAsXml = processor;
+                    if (insertionPt == 1)
+                    {
+                        insertionPoint = editorArray.size();
+                    }
+                    else
+                    {
+                        insertionPoint = 0;
+                    }
 
-                //Sets parameters based on XML files
-                setParametersByXML(p, processor);
-                loadOrder++;
+                    //Point<int> pt =
+                    SourceDetails sd = SourceDetails(processor->getStringAttribute("name"),
+                                                     0,
+                                                     Point<int>(0,0));
 
-                if (p->isSplitter() || p->isMerger())
-                {
-                    splitPoints.add(p);
-                }
+                    itemDropped(sd);
 
-                signalChainManager->updateVisibleEditors(editorArray[0], 0, 0, UPDATE);
+                    p = (GenericProcessor*) lastEditor->getProcessor();
+                    p->loadOrder = loadOrder;
+                    p->parametersAsXml = processor;
 
-            }
-            else if (processor->hasTagName("SWITCH"))
-            {
-                int processorNum = processor->getIntAttribute("number");
+                    //Sets parameters based on XML files
+                    setParametersByXML(p, processor);
+                    loadOrder++;
+
+                    if (p->isSplitter() || p->isMerger())
+                    {
+                        splitPoints.add(p);
+                    }
 
-                std::cout << "SWITCHING number " << processorNum << std::endl;
+                    signalChainManager->updateVisibleEditors(editorArray[0], 0, 0, UPDATE);
 
-                for (int n = 0; n < splitPoints.size(); n++)
+                }
+                else if (processor->hasTagName("SWITCH"))
                 {
+                    int processorNum = processor->getIntAttribute("number");
 
-                    std::cout << "Trying split point " << n
-                              << ", load order: " << splitPoints[n]->loadOrder << std::endl;
+                    std::cout << "SWITCHING number " << processorNum << std::endl;
 
-                    if (splitPoints[n]->loadOrder == processorNum)
+                    for (int n = 0; n < splitPoints.size(); n++)
                     {
 
-                        if (splitPoints[n]->isMerger())
-                        {
-                            std::cout << "Switching merger source." << std::endl;
-                            MergerEditor* editor = (MergerEditor*) splitPoints[n]->getEditor();
-                            editor->switchSource(1);
-                        }
-                        else
+                        std::cout << "Trying split point " << n
+                                  << ", load order: " << splitPoints[n]->loadOrder << std::endl;
+
+                        if (splitPoints[n]->loadOrder == processorNum)
                         {
-                            std::cout << "Switching splitter destination." << std::endl;
-                            SplitterEditor* editor = (SplitterEditor*) splitPoints[n]->getEditor();
-                            editor->switchDest(1);
-                        }
 
-                        splitPoints.remove(n);
+                            if (splitPoints[n]->isMerger())
+                            {
+                                std::cout << "Switching merger source." << std::endl;
+                                MergerEditor* editor = (MergerEditor*) splitPoints[n]->getEditor();
+                                editor->switchSource(1);
+                            }
+                            else
+                            {
+                                std::cout << "Switching splitter destination." << std::endl;
+                                SplitterEditor* editor = (SplitterEditor*) splitPoints[n]->getEditor();
+                                editor->switchDest(1);
+                            }
+
+                            splitPoints.remove(n);
+                        }
                     }
-                }
 
-                signalChainManager->updateVisibleEditors(editorArray[0], 0, 0, UPDATE);
+                    signalChainManager->updateVisibleEditors(editorArray[0], 0, 0, UPDATE);
+
+                }
 
             }
 
         }
-
-        } else if (element->hasTagName("AUDIO"))
+        else if (element->hasTagName("AUDIO"))
         {
             int bufferSize = element->getIntAttribute("bufferSize");
             getAudioComponent()->setBufferSize(bufferSize);
@@ -1592,7 +1599,7 @@ const String EditorViewport::loadState(File fileToLoad)
 
     delete xml;
 
-	currentId=maxID+1; // make sure future processors don't have overlapping id numbers
+    currentId=maxID+1; // make sure future processors don't have overlapping id numbers
 
     return error;
 }
diff --git a/Source/UI/EditorViewport.h b/Source/UI/EditorViewport.h
index d094ae177fc1edbffeae79d659bfd85d5e5b2572..f79e08ea705dfc85f52cd969203a58cf7e9cb05d 100755
--- a/Source/UI/EditorViewport.h
+++ b/Source/UI/EditorViewport.h
@@ -257,7 +257,7 @@ public:
     /** Returns the editor associated with this SignalChainTabButton.*/
     GenericEditor* getEditor()
     {
-         return firstEditor;
+        return firstEditor;
     }
 
     /** Sets the number of this SignalChainTabButton.*/
diff --git a/Source/UI/GraphViewer.cpp b/Source/UI/GraphViewer.cpp
index fa89261f8b9809c02729857ea1d34d0cc3648fcc..6717e7dc4c40e1e0dec373bbc0b5996fca6303a0 100644
--- a/Source/UI/GraphViewer.cpp
+++ b/Source/UI/GraphViewer.cpp
@@ -1,24 +1,24 @@
 /*
  ------------------------------------------------------------------
- 
+
  This file is part of the Open Ephys GUI
  Copyright (C) 2014 Open Ephys
- 
+
  ------------------------------------------------------------------
- 
+
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
- 
+
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
- 
+
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- 
+
  */
 
 #include "GraphViewer.h"
@@ -27,33 +27,33 @@
 
 GraphViewer::GraphViewer()
 {
-    
+
     labelFont = Font("Paragraph", 50, Font::plain);
     rootNum = 0;
 }
 
 GraphViewer::~GraphViewer()
 {
-    
+
 }
 
 void GraphViewer::addNode(GenericEditor* editor)
 {
-    
+
     GraphNode* gn = new GraphNode(editor, this);
     addAndMakeVisible(gn);
     availableNodes.add(gn);
     gn->setBounds(20, 20, 150, 50);
     updateNodeLocations();
-    
+
 }
 
 
 void GraphViewer::removeNode(GenericEditor* editor)
 {
-    
+
     availableNodes.remove(indexOfEditor(editor));
-    
+
     updateNodeLocations();
 
 }
@@ -63,7 +63,7 @@ void GraphViewer::removeAllNodes()
     availableNodes.clear();
 
     updateNodeLocations();
-    
+
 }
 
 // void GenericEditor::updateNodeName(GenericEditor* editor)
@@ -109,7 +109,7 @@ void GraphViewer::updateNodeLocations()
 
 void GraphViewer::checkLayout(GraphNode* gn)
 {
- 
+
     if (gn != nullptr)
     {
 
@@ -132,12 +132,14 @@ void GraphViewer::checkLayout(GraphNode* gn)
                 level2 = getNodeForEditor(editors[1])->getLevel();
             }
 
-           // std::cout << "LEVEL1 = " << level1 << " LEVEL2 = " << level2 << std::endl;
+            // std::cout << "LEVEL1 = " << level1 << " LEVEL2 = " << level2 << std::endl;
 
-            sourceNode = level1 > level2 ? getNodeForEditor(editors[0]) : 
-                                           getNodeForEditor(editors[1]); // choose the higher source
+            sourceNode = level1 > level2 ? getNodeForEditor(editors[0]) :
+                         getNodeForEditor(editors[1]); // choose the higher source
 
-        } else {
+        }
+        else
+        {
             sourceNode = getNodeForEditor(gn->getSource());
         }
 
@@ -146,7 +148,8 @@ void GraphViewer::checkLayout(GraphNode* gn)
             gn->setLevel(0);
             gn->setHorzShift(rootNum);
             rootNum++;
-        } else if (sourceNode->isSplitter()) 
+        }
+        else if (sourceNode->isSplitter())
         {
             Array<GenericEditor*> editors = sourceNode->getConnectedEditors();
 
@@ -154,12 +157,16 @@ void GraphViewer::checkLayout(GraphNode* gn)
             {
                 gn->setLevel(sourceNode->getLevel()+1); // increase level
                 gn->setHorzShift(sourceNode->getHorzShift()+1); // increase horz shift
-            } else {
-                 gn->setLevel(sourceNode->getLevel()+1); // increase level
+            }
+            else
+            {
+                gn->setLevel(sourceNode->getLevel()+1); // increase level
                 gn->setHorzShift(sourceNode->getHorzShift()); // same horz shift
             }
 
-        } else {
+        }
+        else
+        {
 
             gn->setLevel(sourceNode->getLevel()+1); // increase level
             gn->setHorzShift(sourceNode->getHorzShift()); // same horz shift
@@ -174,7 +181,7 @@ void GraphViewer::checkLayout(GraphNode* gn)
 int GraphViewer::indexOfEditor(GenericEditor* editor)
 {
     int index = -1;
-    
+
     for (int i = 0; i < availableNodes.size(); i++)
     {
         if (availableNodes[i]->hasEditor(editor))
@@ -182,7 +189,7 @@ int GraphViewer::indexOfEditor(GenericEditor* editor)
             return i;
         }
     }
-    
+
     return index;
 }
 
@@ -222,7 +229,8 @@ int GraphViewer::getHorizontalShift(GraphNode* gn)
         if (availableNodes[i] == gn)
         {
             break;
-        } else
+        }
+        else
         {
             if (availableNodes[i]->getLevel() == gn->getLevel())
             {
@@ -239,21 +247,21 @@ int GraphViewer::getHorizontalShift(GraphNode* gn)
 void GraphViewer::paint(Graphics& g)
 {
     g.fillAll(Colours::darkgrey);
-    
+
     g.setFont(labelFont);
     g.setFont(50);
-    
+
     g.setColour(Colours::grey);
 
     JUCEApplication* app = JUCEApplication::getInstance();
     String text = "GUI version ";
     text += app->getApplicationVersion();
-    
+
     g.drawFittedText("open ephys", 40, 40, getWidth()-50, getHeight()-60, Justification::bottomRight, 100);
-    
+
     g.setFont(Font("Small Text", 14, Font::plain));
     g.drawFittedText(text, 40, 40, getWidth()-50, getHeight()-45, Justification::bottomRight, 100);
-    
+
     // draw connections
 
     for (int i = 0; i < availableNodes.size(); i++)
@@ -264,22 +272,24 @@ void GraphViewer::paint(Graphics& g)
             if (availableNodes[i]->getDest() != nullptr)
             {
                 int indexOfDest = indexOfEditor(availableNodes[i]->getDest());
-                
+
                 if (indexOfDest > -1)
                     connectNodes(i, indexOfDest, g);
             }
-        } else {
+        }
+        else
+        {
 
             Array<GenericEditor*> editors = availableNodes[i]->getConnectedEditors();
 
             for (int path = 0; path < 2; path++)
             {
                 int indexOfDest = indexOfEditor(editors[path]);
-                    
-                if (indexOfDest > -1)    
+
+                if (indexOfDest > -1)
                     connectNodes(i, indexOfDest, g);
             }
-            
+
 
         }
 
@@ -297,12 +307,12 @@ void GraphViewer::connectNodes(int node1, int node2, Graphics& g)
     float y1 = start.getY();
     float x2 = end.getX();
     float y2 = end.getY();
-    linePath.startNewSubPath (x1, y1);
-    linePath.cubicTo (x1, y1 + (y2 - y1) * 0.9f,
-                      x2, y1 + (y2 - y1) * 0.1f,
-                      x2, y2);
-    
-    PathStrokeType stroke (2.0f);
+    linePath.startNewSubPath(x1, y1);
+    linePath.cubicTo(x1, y1 + (y2 - y1) * 0.9f,
+                     x2, y1 + (y2 - y1) * 0.1f,
+                     x2, y2);
+
+    PathStrokeType stroke(2.0f);
     g.strokePath(linePath, stroke);
 }
 
@@ -319,7 +329,7 @@ GraphNode::GraphNode(GenericEditor* ed, GraphViewer* g)
 
 GraphNode::~GraphNode()
 {
-    
+
 }
 
 int GraphNode::getLevel()
@@ -340,7 +350,7 @@ int GraphNode::getLevel()
 void GraphNode::setLevel(int level)
 {
     setBounds(getX(), 20+level*40, getWidth(), getHeight());
-    
+
     vertShift = level;
 }
 
@@ -354,7 +364,7 @@ void GraphNode::setHorzShift(int shift)
     setBounds(20+shift*140, getY(), getWidth(), getHeight());
     horzShift = shift;
 }
-    
+
 void GraphNode::mouseEnter(const MouseEvent& m)
 {
     mouseOver = true;
@@ -369,7 +379,7 @@ void GraphNode::mouseDown(const MouseEvent& m)
 {
     editor->makeVisible();
 }
-    
+
 bool GraphNode::hasEditor(GenericEditor* ed)
 {
     if (ed == editor)
@@ -427,7 +437,7 @@ void GraphNode::updateBoundaries()
     int level = getLevel();
 
     int horzShift = gv->getHorizontalShift(this);
-    
+
     setBounds(20+horzShift*140, 20+getLevel()*40, 150, 50);
 
 }
@@ -447,7 +457,7 @@ void GraphNode::paint(Graphics& g)
         if (recordStatuses[i])
             recordPath.addPieSegment(0,0,20,20,startRadians,endRadians,0.5);
     }
-    
+
     g.setColour(Colours::red);
     g.fillPath(recordPath);
 
@@ -455,12 +465,14 @@ void GraphNode::paint(Graphics& g)
     {
         g.setColour(Colours::yellow);
         g.fillEllipse(2,2,16,16);
-    } else {
+    }
+    else
+    {
         g.setColour(Colours::lightgrey);
         g.fillEllipse(2,2,16,16);
-    
+
     }
 
     g.drawText(getName(), 25, 0, getWidth()-25, 20, Justification::left, true);
-    
+
 }
\ No newline at end of file
diff --git a/Source/UI/GraphViewer.h b/Source/UI/GraphViewer.h
index 6d19f00c0ea452d21898a489ce0e280fea95f859..29f7555439468d4858527008975dfd562437cb01 100644
--- a/Source/UI/GraphViewer.h
+++ b/Source/UI/GraphViewer.h
@@ -1,24 +1,24 @@
 /*
  ------------------------------------------------------------------
- 
+
  This file is part of the Open Ephys GUI
  Copyright (C) 2014 Open Ephys
- 
+
  ------------------------------------------------------------------
- 
+
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
- 
+
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
- 
+
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- 
+
  */
 
 #ifndef __GRAPHVIEWER_H_4E971BF9__
@@ -30,13 +30,13 @@
 #include "../../JuceLibraryCode/JuceHeader.h"
 
 /**
- 
+
  Displays the full processor graph for a given session.
- 
+
  Inhabits a tab in the DataViewport.
- 
+
  @see UIComponent, DataViewport, ProcessorGraph, EditorViewport
- 
+
  */
 
 
@@ -45,15 +45,15 @@ class GraphNode : public Component
 public:
     GraphNode(GenericEditor* editor, GraphViewer* g);
     ~GraphNode();
-    
+
     void mouseEnter(const MouseEvent& m);
     void mouseExit(const MouseEvent& m);
     void mouseDown(const MouseEvent& m);
-    
+
     bool hasEditor(GenericEditor* editor);
-    
+
     void paint(Graphics& g);
-    
+
     void updateBoundaries();
 
     Point<float> getCenterPoint();
@@ -74,13 +74,13 @@ public:
 
     int horzShift;
     int vertShift;
-    
+
 private:
 
     GenericEditor* editor;
-    
+
     Font labelFont;
-    
+
     bool mouseOver;
 
     GraphViewer* gv;
@@ -92,10 +92,10 @@ class GraphViewer : public Component
 public:
     GraphViewer();
     ~GraphViewer();
-    
+
     /** Draws the GraphViewer.*/
     void paint(Graphics& g);
-    
+
     void addNode(GenericEditor* editor);
     void removeNode(GenericEditor* editor);
     void removeAllNodes();
@@ -111,15 +111,15 @@ private:
     void checkLayout(GraphNode*);
 
     int indexOfEditor(GenericEditor* editor);
-    
+
     Font labelFont;
 
     int rootNum;
-    
+
     OwnedArray<GraphNode> availableNodes;
-    
+
     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(GraphViewer);
-    
+
 };
 
 
diff --git a/Source/UI/ProcessorList.cpp b/Source/UI/ProcessorList.cpp
index 8abc6d0003544b22c20918cab053e18ae6553f2d..7b72f4285b1f4bcea6e345918504cb7201b9f391 100755
--- a/Source/UI/ProcessorList.cpp
+++ b/Source/UI/ProcessorList.cpp
@@ -56,7 +56,7 @@ ProcessorList::ProcessorList()
     //sources->addSubItem(new ProcessorListItem("Custom FPGA"));
     sources->addSubItem(new ProcessorListItem("Rhythm FPGA"));
     sources->addSubItem(new ProcessorListItem("File Reader"));
-	//sources->addSubItem(new ProcessorListItem("Network Events"));
+    //sources->addSubItem(new ProcessorListItem("Network Events"));
     sources->addSubItem(new ProcessorListItem("Serial Port"));
     //sources->addSubItem(new ProcessorListItem("Event Generator"));
 
@@ -67,15 +67,15 @@ ProcessorList::ProcessorList()
     filters->addSubItem(new ProcessorListItem("Phase Detector"));
     //filters->addSubItem(new ProcessorListItem("Digital Ref"));
     filters->addSubItem(new ProcessorListItem("Channel Map"));
-	//filters->addSubItem(new ProcessorListItem("Eye Tracking"));
+    //filters->addSubItem(new ProcessorListItem("Eye Tracking"));
 
 
     ProcessorListItem* sinks = new ProcessorListItem("Sinks");
     sinks->addSubItem(new ProcessorListItem("LFP Viewer"));
     //sinks->addSubItem(new ProcessorListItem("LFP Trig. Avg."));
     sinks->addSubItem(new ProcessorListItem("Spike Viewer"));
-	//sinks->addSubItem(new ProcessorListItem("PSTH"));
-	//sinks->addSubItem(new ProcessorListItem("Network Sink"));
+    //sinks->addSubItem(new ProcessorListItem("PSTH"));
+    //sinks->addSubItem(new ProcessorListItem("Network Sink"));
     //sinks->addSubItem(new ProcessorListItem("WiFi Output"));
     //sinks->addSubItem(new ProcessorListItem("Arduino Output"));
     // sinks->addSubItem(new ProcessorListItem("FPGA Output"));
@@ -461,7 +461,7 @@ void ProcessorList::mouseDown(const MouseEvent& e)
             else
             {
                 getUIComponent()->childComponentChanged();
-               // totalHeight = itemHeight + 2*yBuffer;
+                // totalHeight = itemHeight + 2*yBuffer;
             }
 
         }
@@ -506,7 +506,7 @@ void ProcessorList::mouseDrag(const MouseEvent& e)
                 if (dragDescription.isNotEmpty())
                 {
                     DragAndDropContainer* const dragContainer
-                    = DragAndDropContainer::findParentDragContainerFor(this);
+                        = DragAndDropContainer::findParentDragContainerFor(this);
 
                     if (dragContainer != 0)
                     {
@@ -563,7 +563,7 @@ void ProcessorList::saveStateToXml(XmlElement* xml)
                 break;
             default:
                 // do nothing
-            ;
+                ;
         }
 
         Colour c = findColour(id);
@@ -584,11 +584,11 @@ void ProcessorList::loadStateFromXml(XmlElement* xml)
         {
             forEachXmlChildElement(*xmlNode, colorNode)
             {
-                setColour(colorNode->getIntAttribute("ID"), 
+                setColour(colorNode->getIntAttribute("ID"),
                           Colour(
-                            colorNode->getIntAttribute("R"),
-                            colorNode->getIntAttribute("G"),
-                            colorNode->getIntAttribute("B")));
+                              colorNode->getIntAttribute("R"),
+                              colorNode->getIntAttribute("G"),
+                              colorNode->getIntAttribute("B")));
             }
         }
     }
@@ -607,7 +607,7 @@ Array<Colour> ProcessorList::getColours()
     c.add(findColour(FILTER_COLOR));
     c.add(findColour(SINK_COLOR));
     c.add(findColour(UTILITY_COLOR));
-	return c;
+    return c;
 }
 
 void ProcessorList::setColours(Array<Colour> c)
@@ -636,7 +636,7 @@ void ProcessorList::setColours(Array<Colour> c)
         }
     }
 
-    
+
 }
 
 // ===================================================================
diff --git a/Source/UI/ProcessorList.h b/Source/UI/ProcessorList.h
index 62a5743a7b2432daec4da3df5b1edbd5ffb3d412..f78785a59e2666fd91d31162068e6900faf62e9d 100755
--- a/Source/UI/ProcessorList.h
+++ b/Source/UI/ProcessorList.h
@@ -110,7 +110,7 @@ private:
 
     int currentColor;
 
-    
+
 
     /** Deselects all items within the ProcessorList.*/
     void clearSelectionState();
diff --git a/Source/UI/SignalChainManager.cpp b/Source/UI/SignalChainManager.cpp
index 1ca342a21d3a334c31a0eef41318d5935c90fdcc..9773e3227b32e5aff1936506df51b5a1fa79f36c 100755
--- a/Source/UI/SignalChainManager.cpp
+++ b/Source/UI/SignalChainManager.cpp
@@ -174,7 +174,7 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
     }
     else if (action == MOVE)
     {
-       // std::cout << "    Moving editors." << std::endl;
+        // std::cout << "    Moving editors." << std::endl;
         if (insertionPoint < index)
             editorArray.move(index, insertionPoint);
         else if (insertionPoint > index)
@@ -184,14 +184,14 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
     else if (action == REMOVE)
     {
 
-       // std::cout << "    Removing editor." << std::endl;
+        // std::cout << "    Removing editor." << std::endl;
 
         GenericProcessor* p = (GenericProcessor*) editorArray[index]->getProcessor();
-        
-       // GenericProcessor* source = p->getSourceNode();
+
+        // GenericProcessor* source = p->getSourceNode();
         if (p->getSourceNode() != nullptr)
-			if (p->getSourceNode()->isSplitter())
-				p->getSourceNode()->setSplitterDestNode(nullptr);
+            if (p->getSourceNode()->isSplitter())
+                p->getSourceNode()->setSplitterDestNode(nullptr);
 
         // if the processor to be removed is a merger,
         // we need to inform the other source that its merger has disappeared
@@ -202,14 +202,14 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
                 p->getSourceNode()->setDestNode(nullptr);
         }
 
-        // if the processor to be removed is a splitter, we need to make sure 
+        // if the processor to be removed is a splitter, we need to make sure
         // there aren't any orphaned processors
         if (p->isSplitter())
         {
             p->switchIO(0);
             if (p->getDestNode() != nullptr)
             {
-             //   std::cout << "Found an orphaned signal chain" << std::endl;
+                //   std::cout << "Found an orphaned signal chain" << std::endl;
                 p->getDestNode()->setSourceNode(nullptr);
                 createNewTab(p->getDestNode()->getEditor());
             }
@@ -217,7 +217,7 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
             p->switchIO(1);
             if (p->getDestNode() != nullptr)
             {
-             //   std::cout << "Found an orphaned signal chain" << std::endl;
+                //   std::cout << "Found an orphaned signal chain" << std::endl;
                 p->getDestNode()->setSourceNode(nullptr);
                 createNewTab(p->getDestNode()->getEditor());
             }
@@ -238,12 +238,12 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
             merger = (p2->isMerger() && p2->stillHasSource());
             if (merger)
             {
-              //  std::cout << "We've got a merger!" << std::endl;
+                //  std::cout << "We've got a merger!" << std::endl;
                 //p2->switchIO(0);
                 p2->setMergerSourceNode(p->getSourceNode());
                 MergerEditor* me = (MergerEditor*) editorArray[0];
                 me->switchSource();
-               // p2->setMergerSourceNode(nullptr);
+                // p2->setMergerSourceNode(nullptr);
             }
         }
 
@@ -266,7 +266,7 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
         else
         {
 
-           // std::cout << "Tab number " << t << std::endl;
+            // std::cout << "Tab number " << t << std::endl;
 
             removeTab(t);
 
@@ -288,14 +288,14 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
     else     //no change
     {
 
-       // std::cout << "Activating editor" << std::endl;
+        // std::cout << "Activating editor" << std::endl;
     }
 
     // Step 2: update connections
     if (action != ACTIVATE && action != UPDATE && editorArray.size() > 0)
     {
 
-       // std::cout << "Updating connections." << std::endl;
+        // std::cout << "Updating connections." << std::endl;
 
         GenericProcessor* source = 0;
         GenericProcessor* dest = (GenericProcessor*) editorArray[0]->getProcessor();
@@ -319,7 +319,7 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
     if (action != ACTIVATE && action != UPDATE)
     {
 
-      //  std::cout << "Checking for new tabs." << std::endl;
+        //  std::cout << "Checking for new tabs." << std::endl;
 
         for (int n = 0; n < editorArray.size(); n++)
         {
@@ -333,7 +333,7 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
                 {
                     if (!p->isMerger())
                     {
-                     //   std::cout << p->getName() << " has no source node. Creating a new tab." << std::endl;
+                        //   std::cout << p->getName() << " has no source node. Creating a new tab." << std::endl;
                         createNewTab(editorArray[n]);
                     }
                 }
@@ -351,7 +351,7 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
 
             if (p->isMerger())
             {
-               // std::cout << "It's a merger!" << std::endl;
+                // std::cout << "It's a merger!" << std::endl;
                 //createNewTab(editorArray[n]);
             }
         }
@@ -364,13 +364,13 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
     }
 
     editorArray.clear();
-   // std::cout << "Cleared editor array." << std::endl;
+    // std::cout << "Cleared editor array." << std::endl;
 
     GenericEditor* editorToAdd = activeEditor;
 
     while (editorToAdd != 0)
     {
-       // std::cout << "Inserting " << editorToAdd->getName() << " at point 0." << std::endl;
+        // std::cout << "Inserting " << editorToAdd->getName() << " at point 0." << std::endl;
 
         editorArray.insert(0,editorToAdd);
         GenericProcessor* currentProcessor = (GenericProcessor*) editorToAdd->getProcessor();
@@ -378,15 +378,15 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
 
         if (source != nullptr)
         {
-         //   std::cout << "Source: " << source->getName() << std::endl;
+            //   std::cout << "Source: " << source->getName() << std::endl;
 
             // need to switch the splitter somehow
             if (action == ACTIVATE || action == UPDATE)
             {
-             if (source->isSplitter())
-             {
-                 source->setPathToProcessor(currentProcessor);
-             }
+                if (source->isSplitter())
+                {
+                    source->setPathToProcessor(currentProcessor);
+                }
             }
 
             editorToAdd = (GenericEditor*) source->getEditor();
@@ -398,7 +398,7 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
             if (editorToAdd->tabNumber() >= 0 && editorToAdd->tabNumber() < signalChainArray.size())
                 signalChainArray[editorToAdd->tabNumber()]->setToggleState(true, dontSendNotification);
 
-           // std::cout << "No source found." << std::endl;
+            // std::cout << "No source found." << std::endl;
             editorToAdd = 0;
 
         }
@@ -415,14 +415,14 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
         if (dest != 0)
         {
 
-         //   std::cout << "Destination: " << dest->getName() << std::endl;
+            //   std::cout << "Destination: " << dest->getName() << std::endl;
             editorToAdd = (GenericEditor*) dest->getEditor();
             editorArray.add(editorToAdd);
-         //   std::cout << "Inserting " << editorToAdd->getName() << " at the end." << std::endl;
+            //   std::cout << "Inserting " << editorToAdd->getName() << " at the end." << std::endl;
 
             if (dest->isMerger())
             {
-            //    std::cout << "It's a merger!" << std::endl;
+                //    std::cout << "It's a merger!" << std::endl;
 
                 editorToAdd->switchIO(0);
 
@@ -434,7 +434,7 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
         }
         else
         {
-         //   std::cout << "No dest found." << std::endl;
+            //   std::cout << "No dest found." << std::endl;
             editorToAdd = 0;
         }
 
@@ -484,10 +484,10 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
                     }
                 }
 
-             //   if (enable)
-              //      std::cout << "Enabling node." << std::endl;
-             //   else
-               //     std::cout << "Not enabling node." << std::endl;
+                //   if (enable)
+                //      std::cout << "Enabling node." << std::endl;
+                //   else
+                //     std::cout << "Not enabling node." << std::endl;
 
                 editorArray[n+1]->setEnabledState(enable);
 
@@ -508,7 +508,7 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
     if (action != ACTIVATE)
     {
 
-       // std::cout << "Updating settings." << std::endl;
+        // std::cout << "Updating settings." << std::endl;
 
         Array<GenericProcessor*> splitters;
 
@@ -519,9 +519,9 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
             GenericEditor* source = signalChainArray[n]->getEditor();
             GenericProcessor* p = source->getProcessor();
 
-          //  p->update();
+            //  p->update();
 
-          //  GenericProcessor* dest = p->getDestNode();
+            //  GenericProcessor* dest = p->getDestNode();
 
             while (p != 0)
             {
@@ -547,6 +547,6 @@ void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
     }
 
 
-   // std::cout << "Finished adding new editor." << std::endl << std::endl << std::endl;
+    // std::cout << "Finished adding new editor." << std::endl << std::endl << std::endl;
 
 }
diff --git a/Source/UI/UIComponent.cpp b/Source/UI/UIComponent.cpp
index 535be609edaf592e545c68874c8d6c3f1c867c6f..5a8e90380c79b703f0db92a97ccd1a258813c947 100755
--- a/Source/UI/UIComponent.cpp
+++ b/Source/UI/UIComponent.cpp
@@ -75,13 +75,13 @@ UIComponent::UIComponent(MainWindow* mainWindow_, ProcessorGraph* pgraph, AudioC
     setBounds(0,0,500,400);
 
     processorGraph->setUIComponent(this);
-    
+
     processorList->setUIComponent(this);
     editorViewport->setUIComponent(this);
     dataViewport->setUIComponent(this);
     controlPanel->getAudioEditor()->setUIComponent(this);
     controlPanel->setUIComponent(this);
-    
+
     processorGraph->updatePointers(); // needs to happen after processorGraph gets the right pointers
 
 #if JUCE_MAC
@@ -131,7 +131,7 @@ void UIComponent::resized()
 
         editorViewport->setBounds(6,h-190,w-11,150);
 
-        
+
     }
 
     if (controlPanel != 0)
@@ -141,10 +141,12 @@ void UIComponent::resized()
         int addHeight = 0;
         int leftBound;
 
-        if (w >= 460){
+        if (w >= 460)
+        {
             leftBound = 202;
         }
-        else {
+        else
+        {
             leftBound = w-258;
             controlPanelWidth = w-leftBound;
         }
@@ -183,10 +185,11 @@ void UIComponent::resized()
             processorListViewport.setScrollBarsShown(true,false);
 
         }
-        else{
+        else
+        {
             processorListViewport.setBounds(5,5,195,34);
             processorListViewport.setScrollBarsShown(false,false);
-            processorListViewport.setViewPosition (0, 0);
+            processorListViewport.setViewPosition(0, 0);
         }
 
         if (w < 460)
@@ -215,22 +218,22 @@ void UIComponent::resized()
 
         dataViewport->setBounds(left, top, width, height);
 
-         if (h < 200)
+        if (h < 200)
             dataViewport->setVisible(false);
         else
             dataViewport->setVisible(true);
 
     }
 
-    
+
 
     if (messageCenter != 0)
     {
         messageCenter->setBounds(6,h-35,w-241,30);
         if (h < 200)
             messageCenter->setBounds(6,h-35+200-h,w-241,30);
-      //  else
-      //      messageCenter->setVisible(true);
+        //  else
+        //      messageCenter->setVisible(true);
     }
 
     // for debugging purposes:
@@ -446,7 +449,7 @@ void UIComponent::getCommandInfo(CommandID commandID, ApplicationCommandInfo& re
             result.setInfo("Show help...", "Take me to the GUI wiki.", "General", 0);
             result.setActive(true);
             break;
-            
+
         case resizeWindow:
             result.setInfo("Reset window bounds", "Reset window bounds", "General", 0);
             break;
@@ -487,7 +490,9 @@ bool UIComponent::perform(const InvocationInfo& info)
                 if (currentConfigFile.exists())
                 {
                     sendActionMessage(getEditorViewport()->saveState(currentConfigFile));
-                } else {
+                }
+                else
+                {
                     FileChooser fc("Choose the file name...",
                                    File::getCurrentWorkingDirectory(),
                                    "*",
@@ -538,17 +543,17 @@ bool UIComponent::perform(const InvocationInfo& info)
             break;
 
         case clearSignalChain:
-        {
-            getEditorViewport()->clearSignalChain();
-            break;
-        }
+            {
+                getEditorViewport()->clearSignalChain();
+                break;
+            }
 
         case showHelp:
-        {
-            URL url = URL("https://open-ephys.atlassian.net/wiki/display/OEW/Open+Ephys+GUI");
-            url.launchInDefaultBrowser();
-            break;
-        }
+            {
+                URL url = URL("https://open-ephys.atlassian.net/wiki/display/OEW/Open+Ephys+GUI");
+                url.launchInDefaultBrowser();
+                break;
+            }
 
         case toggleProcessorList:
             processorList->toggleState();
@@ -561,7 +566,7 @@ bool UIComponent::perform(const InvocationInfo& info)
         case toggleSignalChain:
             editorViewportButton->toggleState();
             break;
-            
+
         case resizeWindow:
             mainWindow->centreWithSize(800, 600);
             break;
diff --git a/Source/UI/UIComponent.h b/Source/UI/UIComponent.h
index 1ae16db58496d5bc299540c5dd2f3d9aed3ee147..66caa4d1e4322374ba0ba0d20350203ab18ed7ee 100755
--- a/Source/UI/UIComponent.h
+++ b/Source/UI/UIComponent.h
@@ -90,7 +90,7 @@ public:
     {
         return processorGraph;
     }
-    
+
     /** Returns a pointer to the GraphViewer. */
     GraphViewer* getGraphViewer()
     {
@@ -176,7 +176,7 @@ private:
     ScopedPointer<GraphViewer> graphViewer;
 
     Viewport processorListViewport;
-	
+
     /** Pointer to the GUI's MainWindow, which owns the UIComponent. */
     MainWindow* mainWindow;