Merge branch 'upstream'

Integrate from SVN upstream, version 1396.

All conflicts resolved by hand.

Conflicts:
	src/libprojectM/MilkdropPresetFactory/BuiltinFuncs.hpp
	src/libprojectM/MilkdropPresetFactory/Expr.cpp
	src/libprojectM/Renderer/Renderer.cpp
	src/libprojectM/config.inp.in
	src/libprojectM/projectM.cpp
diff --git a/AUTHORS.txt b/AUTHORS.txt
index 7544527..b25ef5e 100644
--- a/AUTHORS.txt
+++ b/AUTHORS.txt
@@ -1,46 +1,46 @@
-projectM -- Milkdrop-esque visualisation SDK

-Copyright (C)2003-2007 projectM Team

-

-This library is free software; you can redistribute it and/or

-modify it under the terms of the GNU Lesser General Public

-License as published by the Free Software Foundation; either

-version 2.1 of the License, or (at your option) any later version.

-

-This library 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

-Lesser General Public License for more details.

-

-You should have received a copy of the GNU Lesser General Public

-License along with this library; if not, write to the Free Software

-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

-See 'LICENSE.txt' included within this release

-

-For the purposes of the copyright statement in the preamble of each source

-code file comprising projectM, the projectM team are:

-

-Carmelo Piccione

-    Parser

-    Evaluator

-    Pulse Audio support (projectM-pulseaudio)

-    Qt GUI (projectM-qt)

-

-Peter Sperl

-    Beat Detection

-    Rendering

-    XMMS Support (projectM-xmms)

-    libvisual Support (projectM-libvisual)

-

-Alligator Descartes

-    Media Player Support (iTunes, Winamp, Windows Media Player)

-    Test application frameworks (projectM-wxvis, projectM-sdlvis)

-    DVD application (projectM-movie)

-    Win32 screensaver (projectM-screensaver)

-

-Roger Dannenburg

-    Advice & Support

-

-Matthias Klumpp

-    CMake build system

-    Distro integration

-    Bug fixes

+projectM -- Milkdrop-esque visualisation SDK
+Copyright (C)2003-2007 projectM Team
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+See 'LICENSE.txt' included within this release
+
+For the purposes of the copyright statement in the preamble of each source
+code file comprising projectM, the projectM team are:
+
+Carmelo Piccione
+    Parser
+    Evaluator
+    Pulse Audio support (projectM-pulseaudio)
+    Qt GUI (projectM-qt)
+
+Peter Sperl
+    Beat Detection
+    Rendering
+    XMMS Support (projectM-xmms)
+    libvisual Support (projectM-libvisual)
+
+Alligator Descartes
+    Media Player Support (iTunes, Winamp, Windows Media Player)
+    Test application frameworks (projectM-wxvis, projectM-sdlvis)
+    DVD application (projectM-movie)
+    Win32 screensaver (projectM-screensaver)
+
+Roger Dannenburg
+    Advice & Support
+
+Matthias Klumpp
+    CMake build system
+    Distro integration
+    Bug fixes
diff --git a/src/libprojectM/CMakeLists.txt b/src/libprojectM/CMakeLists.txt
index acc698e..c3dae7a 100644
--- a/src/libprojectM/CMakeLists.txt
+++ b/src/libprojectM/CMakeLists.txt
@@ -19,8 +19,6 @@
 
 OPTION (USE_OPENMP "Use OpenMP and OMPTL for multi-core parallelization" ON)
 
-OPTION (USE_NATIVE_GLEW "Use projectM's native implemention of GLEW." OFF)
-
 OPTION (USE_CG "Use Cg for Pixel Shader support" OFF)
 
 OPTION (BUILD_PROJECTM_STATIC "Build the projectM target library in the platform's native static (NOT shared) format." OFF)
@@ -39,17 +37,10 @@
   CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib)"
   FORCE)
 
-if (USE_NATIVE_GLEW)
-ADD_DEFINITIONS(-DUSE_NATIVE_GLEW)
- SET(GLEW_SOURCES glew.h glew.c)
- SET(GLEW_LIBRARY "")
-else(USE_NATIVE_GLEW)
- set (GLEW_SOURCES "")
- find_package (GLEW)
-endif(USE_NATIVE_GLEW)
+ADD_DEFINITIONS(-DSINGLE_PROCESS)
 
 SET(projectM_SOURCES projectM.cpp PCM.cpp Preset.cpp fftsg.cpp KeyHandler.cpp
-timer.cpp wipemalloc.cpp PresetLoader.cpp  PresetChooser.cpp PipelineMerger.cpp ConfigFile.cpp  TimeKeeper.cpp PresetFactory.cpp PresetFactoryManager.cpp ${GLEW_SOURCES})
+timer.cpp wipemalloc.cpp PresetLoader.cpp  PresetChooser.cpp PipelineMerger.cpp ConfigFile.cpp  TimeKeeper.cpp PresetFactory.cpp PresetFactoryManager.cpp)
 
 if (MSVC)
 SET(projectM_SOURCES ${projectM_SOURCES} dlfcn.c win32-dirent.cpp)
@@ -196,7 +187,6 @@
 				${IMAGE_LINK_TARGETS}
 				${CG_LINK_TARGETS}
 				${PRESET_FACTORY_LINK_TARGETS}
-				${GLEW_LIBRARY}
 				${FTGL_LINK_TARGETS}
 				${MATH_LIBRARIES}
 				dl
@@ -207,7 +197,6 @@
 				${IMAGE_LINK_TARGETS}
 				${CG_LINK_TARGETS}
 				${PRESET_FACTORY_LINK_TARGETS}
-				${GLEW_LIBRARY}
 				${FTGL_LINK_TARGETS}
 				${MATH_LIBRARIES}
 				dl
diff --git a/src/libprojectM/Common.hpp b/src/libprojectM/Common.hpp
index b292495..843422b 100644
--- a/src/libprojectM/Common.hpp
+++ b/src/libprojectM/Common.hpp
@@ -26,20 +26,22 @@
 
 #ifndef COMMON_HPP
 #define COMMON_HPP
+
 #include <vector>
 #include <typeinfo>
 #include <cstdarg>
 #include <cassert>
+
 #ifdef _MSC_sVER
-#define strcasecmp(s, t) _strcmpi(s, t)
+#define strcasecmp(s, t)    _strcmpi(s, t)
 #endif
 
 #ifdef _MSC_VER
-	#pragma warning( disable : 4244 4305 4996; once : 4018 )
-	#define WIN32_LEAN_AND_MEAN
-	#define NOMINMAX
-	#include <windows.h>
-	typedef unsigned int uint;
+  #pragma warning( disable : 4244 4305 4996; once : 4018 )
+  #define WIN32_LEAN_AND_MEAN
+  #define NOMINMAX
+  #include <windows.h>
+  typedef unsigned int uint;
 #endif
 
 #ifdef DEBUG
@@ -48,198 +50,183 @@
 
 #ifdef MACOS
 #include <cstdio>
-extern FILE *fmemopen(void *buf, size_t len, const char *pMode);
+extern FILE *fmemopen (void *buf, size_t len, const char *pMode);
 #endif /** MACOS */
 
 #include "dlldefs.h"
 
-#define DEFAULT_FONT_PATH "/home/carm/fonts/courier1.glf"
-#define MAX_TOKEN_SIZE 512
-#define MAX_PATH_SIZE 4096
+#define DEFAULT_FONT_PATH   "/home/carm/fonts/courier1.glf"
+#define MAX_TOKEN_SIZE      512
+#define MAX_PATH_SIZE       4096
 
-#define STRING_BUFFER_SIZE 1024*150
-#define STRING_LINE_SIZE 1024
+#define STRING_BUFFER_SIZE  1024*150
+#define STRING_LINE_SIZE    1024
 
 
 #ifdef LINUX
 #include <cstdlib>
-#define projectM_isnan isnan
-
+#define projectM_isnan      std::isnan
+#define projectM_fmax       fmax
+#define projectM_fmin       fmin
 #endif
 
 #ifdef WIN32
-#define projectM_isnan(x) ((x) != (x))
+#define projectM_isnan(x)   ((x) != (x))
+#define projectM_fmax(x,y)  ((x) >= (y) ? (x): (y))
+#define projectM_fmin(x,y)  ((x) <= (y) ? (x): (y))
 #endif
 
 #ifdef MACOS
-#define projectM_isnan(x) ((x) != (x))
-#endif
-
-#ifdef LINUX
-#define projectM_fmax fmax
-#endif
-
-#ifdef WIN32
-#define projectM_fmax(x,y) ((x) >= (y) ? (x): (y))
-#endif
-
-#ifdef MACOS
-#define projectM_fmax(x,y) ((x) >= (y) ? (x): (y))
-#endif
-
-#ifdef LINUX
-#define projectM_fmin fmin
-#endif
-
-#ifdef WIN32
-#define projectM_fmin(x,y) ((x) <= (y) ? (x): (y))
-#endif
-
-#ifdef MACOS
-#define projectM_fmin(x,y) ((x) <= (y) ? (x): (y))
+#define projectM_isnan(x)   ((x) != (x))
+#define projectM_fmax(x,y)  ((x) >= (y) ? (x): (y))
+#define projectM_fmin(x,y)  ((x) <= (y) ? (x): (y))
 #endif
 
 #ifndef TRUE
-#define TRUE true
+#define TRUE                true
 #endif
 
 #ifndef FALSE
-#define FALSE false
+#define FALSE               false
 #endif
 
 
-#define MAX_DOUBLE_SIZE  10000000.0
-#define MIN_DOUBLE_SIZE -10000000.0
+#define MAX_DOUBLE_SIZE      10000000.0
+#define MIN_DOUBLE_SIZE     -10000000.0
 
-#define MAX_INT_SIZE  10000000
-#define MIN_INT_SIZE -10000000
+#define MAX_INT_SIZE         10000000
+#define MIN_INT_SIZE        -10000000
 
 /* default float initial value */
-#define DEFAULT_DOUBLE_IV 0.0
+#define DEFAULT_DOUBLE_IV   0.0
 
 /* default float lower bound */
-#define DEFAULT_DOUBLE_LB MIN_DOUBLE_SIZE
+#define DEFAULT_DOUBLE_LB   MIN_DOUBLE_SIZE
 
 /* default float upper bound */
-#define DEFAULT_DOUBLE_UB MAX_DOUBLE_SIZE
+#define DEFAULT_DOUBLE_UB   MAX_DOUBLE_SIZE
 
 #ifdef WIN32
 #include <float.h>
-#define isnan _isnan
+#define isnan               _isnan
 #endif /** WIN32 */
 
 /** Per-platform path separators */
-#define WIN32_PATH_SEPARATOR '\\'
-#define UNIX_PATH_SEPARATOR '/'
+#define WIN32_PATH_SEPARATOR  '\\'
+#define UNIX_PATH_SEPARATOR   '/'
 #ifdef WIN32
-#define PATH_SEPARATOR WIN32_PATH_SEPARATOR
+#define PATH_SEPARATOR        WIN32_PATH_SEPARATOR
 #else
-#define PATH_SEPARATOR UNIX_PATH_SEPARATOR
+#define PATH_SEPARATOR        UNIX_PATH_SEPARATOR
 #endif /** WIN32 */
+
 #include <string>
 
-const unsigned int NUM_Q_VARIABLES(32);
-const std::string PROJECTM_FILE_EXTENSION("prjm");
-const std::string MILKDROP_FILE_EXTENSION("milk");
-const std::string PROJECTM_MODULE_EXTENSION("so");
 
- template <class TraverseFunctor, class Container>
-  void traverse(Container & container)
+const unsigned int  NUM_Q_VARIABLES (32);
+const std::string   PROJECTM_FILE_EXTENSION ("prjm");
+const std::string   MILKDROP_FILE_EXTENSION ("milk");
+const std::string   PROJECTM_MODULE_EXTENSION ("so");
+
+
+template <class TraverseFunctor, class Container>
+void traverse (Container & container)
+{
+  TraverseFunctor functor;
+
+  for (typename Container::iterator pos = container.begin ();
+       pos != container.end ();
+       ++pos)
   {
-
-    TraverseFunctor functor;
-
-    for (typename Container::iterator pos = container.begin(); pos != container.end(); ++pos)
-    {
-      assert(pos->second);
-      functor(pos->second);
-    }
-
+    assert (pos->second);
+    functor (pos->second);
   }
 
-
-  template <class TraverseFunctor, class Container>
-  void traverseVector(Container & container)
-  {
-
-    TraverseFunctor functor;
-
-    for (typename Container::iterator pos = container.begin(); pos != container.end(); ++pos)
-    {
-      assert(*pos);
-      functor(*pos);
-    }
-
-  }
-
-  template <class TraverseFunctor, class Container>
-  void traverse(Container & container, TraverseFunctor & functor)
-  {
-
-    for (typename Container::iterator pos = container.begin(); pos != container.end(); ++pos)
-    {
-      assert(pos->second);
-      functor(pos->second);
-    }
-
-  }
-
-  namespace TraverseFunctors
-  {
-    template <class Data>
-    class Delete
-    {
-
-    public:
-
-      void operator() (Data * data)
-      {
-        assert(data);
-        delete(data);
-      }
-
-    };
-  }
-
-
-inline std::string parseExtension(const std::string & filename) {
-
-const std::size_t start = filename.find_last_of('.');
-
-if (start == std::string::npos || start >= (filename.length()-1))
-	return "";
-else
-	return filename.substr(start+1, filename.length());
-
 }
 
-inline std::string parseFilename(const std::string & filename) {
 
-const std::size_t start = filename.find_last_of('/');
+template <class TraverseFunctor, class Container>
+void traverseVector (Container & container)
+{
+  TraverseFunctor functor;
 
-if (start == std::string::npos || start >= (filename.length()-1))
-	return "";
-else
-	return filename.substr(start+1, filename.length());
+  for (typename Container::iterator pos = container.begin ();
+       pos != container.end ();
+       ++pos)
+  {
+    assert (*pos);
+    functor (*pos);
+  }
 
 }
 
-inline double meanSquaredError(const double & x, const double & y) {
-		return (x-y)*(x-y);
+template <class TraverseFunctor, class Container>
+void traverse (Container & container, TraverseFunctor & functor)
+{
+  for (typename Container::iterator pos = container.begin ();
+       pos != container.end ();
+       ++pos)
+  {
+    assert (pos->second);
+    functor (pos->second);
+  }
+
+}
+
+namespace TraverseFunctors
+{
+  template <class Data>
+  class Delete
+  {
+
+  public:
+
+    void
+    operator () (Data * data)
+    {
+      assert (data);
+      delete (data);
+    }
+
+  };
+} /*  namespace TraverseFunctors  */
+
+
+inline std::string
+parseExtension (const std::string & filename) {
+  const std::size_t start = filename.find_last_of ('.');
+
+  if (start == std::string::npos  ||  start >= (filename.length ()-1))
+    return "";
+  else
+    return filename.substr (start+1, filename.length ());
+}
+
+inline std::string
+parseFilename (const std::string & filename) {
+  const std::size_t start = filename.find_last_of ('/');
+
+  if (start == std::string::npos || start >= (filename.length ()-1))
+    return "";
+  else
+    return filename.substr (start+1, filename.length ());
+}
+
+inline double
+meanSquaredError (const double & x, const double & y) {
+  return (x-y)*(x-y);
 }
 
 
 enum PresetRatingType {
-	FIRST_RATING_TYPE = 0,
-	HARD_CUT_RATING_TYPE = FIRST_RATING_TYPE,
-	SOFT_CUT_RATING_TYPE,
-	LAST_RATING_TYPE = SOFT_CUT_RATING_TYPE,
-	TOTAL_RATING_TYPES = SOFT_CUT_RATING_TYPE+1
+  FIRST_RATING_TYPE     = 0,
+  HARD_CUT_RATING_TYPE  = FIRST_RATING_TYPE,
+  SOFT_CUT_RATING_TYPE,
+  LAST_RATING_TYPE      = SOFT_CUT_RATING_TYPE,
+  TOTAL_RATING_TYPES    = SOFT_CUT_RATING_TYPE+1
 };
 
 
 typedef std::vector<int> RatingList;
 
 #endif
-
-
diff --git a/src/libprojectM/ConfigFile.cpp b/src/libprojectM/ConfigFile.cpp
index f041064..c10662d 100644
--- a/src/libprojectM/ConfigFile.cpp
+++ b/src/libprojectM/ConfigFile.cpp
@@ -1,142 +1,158 @@
-// ConfigFile.cpp

-

-#include "ConfigFile.h"

-

-using std::string;

-

-ConfigFile::ConfigFile( string filename, string delimiter,

-                        string comment, string sentry )

-	: myDelimiter(delimiter), myComment(comment), mySentry(sentry)

-{

-	// Construct a ConfigFile, getting keys and values from given file

-	

-	std::ifstream in( filename.c_str() );

-	

-	if( !in ) throw file_not_found( filename ); 

-	

-	in >> (*this);

-}

-

-

-ConfigFile::ConfigFile()

-	: myDelimiter( string(1,'=') ), myComment( string(1,'#') )

-{

-	// Construct a ConfigFile without a file; empty

-}

-

-

-void ConfigFile::remove( const string& key )

-{

-	// Remove key and its value

-	myContents.erase( myContents.find( key ) );

-	return;

-}

-

-

-bool ConfigFile::keyExists( const string& key ) const

-{

-	// Indicate whether key is found

-	mapci p = myContents.find( key );

-	return ( p != myContents.end() );

-}

-

-

-/* static */

-void ConfigFile::trim( string& s )

-{

-	// Remove leading and trailing whitespace

-	static const char whitespace[] = " \n\t\v\r\f";

-	s.erase( 0, s.find_first_not_of(whitespace) );

-	s.erase( s.find_last_not_of(whitespace) + 1U );

-}

-

-

-std::ostream& operator<<( std::ostream& os, const ConfigFile& cf )

-{

-	// Save a ConfigFile to os

-	for( ConfigFile::mapci p = cf.myContents.begin();

-	     p != cf.myContents.end();

-		 ++p )

-	{

-		os << p->first << " " << cf.myDelimiter << " ";

-		os << p->second << std::endl;

-	}

-	return os;

-}

-

-

-std::istream& operator>>( std::istream& is, ConfigFile& cf )

-{

-	// Load a ConfigFile from is

-	// Read in keys and values, keeping internal whitespace

-	typedef string::size_type pos;

-	const string& delim  = cf.myDelimiter;  // separator

-	const string& comm   = cf.myComment;    // comment

-	const string& sentry = cf.mySentry;     // end of file sentry

-	const pos skip = delim.length();        // length of separator

-	

-	string nextline = "";  // might need to read ahead to see where value ends

-	

-	while( is || nextline.length() > 0 )

-	{

-		// Read an entire line at a time

-		string line;

-		if( nextline.length() > 0 )

-		{

-			line = nextline;  // we read ahead; use it now

-			nextline = "";

-		}

-		else

-		{

-			std::getline( is, line );

-		}

-		

-		// Ignore comments

-		line = line.substr( 0, line.find(comm) );

-		

-		// Check for end of file sentry

-		if( sentry != "" && line.find(sentry) != string::npos ) return is;

-		

-		// Parse the line if it contains a delimiter

-		pos delimPos = line.find( delim );

-		if( delimPos < string::npos )

-		{

-			// Extract the key

-			string key = line.substr( 0, delimPos );

-			line.replace( 0, delimPos+skip, "" );

-			

-			// See if value continues on the next line

-			// Stop at blank line, next line with a key, end of stream,

-			// or end of file sentry

-			bool terminate = false;

-			while( !terminate && is )

-			{

-				std::getline( is, nextline );

-				terminate = true;

-				

-				string nlcopy = nextline;

-				ConfigFile::trim(nlcopy);

-				if( nlcopy == "" ) continue;

-				

-				nextline = nextline.substr( 0, nextline.find(comm) );

-				if( nextline.find(delim) != string::npos )

-					continue;

-				if( sentry != "" && nextline.find(sentry) != string::npos )

-					continue;

-				

-				nlcopy = nextline;

-				ConfigFile::trim(nlcopy);

-				if( nlcopy != "" ) line += "\n";

-				line += nextline;

-				terminate = false;

-			}

-			

-			// Store key and value

-			ConfigFile::trim(key);

-			ConfigFile::trim(line);

-			cf.myContents[key] = line;  // overwrites if key is repeated

-		}

-	}

-	

-	return is;

-}

+// ConfigFile.cpp
+
+#include "ConfigFile.h"
+
+
+using std::string;
+
+ConfigFile::ConfigFile (
+string filename,
+string delimiter,
+string comment,
+string sentry
+)
+  : myDelimiter (delimiter),
+    myComment (comment),
+    mySentry (sentry)
+{
+  // Construct a ConfigFile, getting keys and values from given file
+
+  std::ifstream in (filename.c_str ());
+
+  if (!in) throw file_not_found (filename);
+
+  in >> (*this);
+}
+
+
+ConfigFile::ConfigFile ()
+  : myDelimiter (string (1,'=')),
+    myComment (string (1,'#'))
+{
+  // Construct a ConfigFile without a file; empty
+}
+
+
+void
+ConfigFile::remove (const string& key)
+{
+  // Remove key and its value
+  myContents.erase (myContents.find (key));
+  return;
+}
+
+
+bool
+ConfigFile::keyExists (const string& key) const
+{
+  // Indicate whether key is found
+  mapci p = myContents.find (key);
+
+  return (p != myContents.end ());
+}
+
+
+/* static */
+void
+ConfigFile::trim (string& s)
+{
+  // Remove leading and trailing whitespace
+  static const char whitespace[] = " \n\t\v\r\f";
+
+  s.erase (0, s.find_first_not_of (whitespace));
+  s.erase (s.find_last_not_of (whitespace) + 1U);
+}
+
+
+std::ostream&
+operator<< (std::ostream& os, const ConfigFile& cf)
+{
+  // Save a ConfigFile to os
+  for (ConfigFile::mapci p = cf.myContents.begin ();
+       p != cf.myContents.end ();
+       ++p)
+  {
+    os << p->first << " " << cf.myDelimiter << " ";
+    os << p->second << std::endl;
+  }
+  return os;
+}
+
+
+std::istream&
+operator>> (std::istream& is, ConfigFile& cf)
+{
+  // Load a ConfigFile from is
+  // Read in keys and values, keeping internal whitespace
+  typedef string::size_type pos;
+  const string              &delim  = cf.myDelimiter; // separator
+  const string              &comm   = cf.myComment;   // comment
+  const string              &sentry = cf.mySentry;    // end of file sentry
+  const pos                 skip = delim.length ();   // length of separator
+
+  string nextline = "";  // might need to read ahead to see where value ends
+
+  while (is  ||  nextline.length () > 0)
+  {
+    // Read an entire line at a time
+    string line;
+
+    if (nextline.length () > 0)
+    {
+      line = nextline;  // we read ahead; use it now
+      nextline = "";
+    }
+    else
+    {
+      std::getline (is, line);
+    }
+
+    // Ignore comments
+    line = line.substr (0, line.find (comm));
+
+    // Check for end of file sentry
+    if (sentry != ""  &&  line.find (sentry) != string::npos) return is;
+
+    // Parse the line if it contains a delimiter
+    pos delimPos = line.find (delim);
+    if (delimPos < string::npos)
+    {
+      // Extract the key
+      string key = line.substr (0, delimPos);
+      line.replace (0, delimPos+skip, "");
+
+      // See if value continues on the next line
+      // Stop at blank line, next line with a key, end of stream,
+      // or end of file sentry
+      bool terminate = false;
+      while (!terminate  &&  is)
+      {
+        std::getline (is, nextline);
+        terminate = true;
+
+        string nlcopy = nextline;
+        ConfigFile::trim (nlcopy);
+        if (nlcopy == "") continue;
+
+        nextline = nextline.substr (0, nextline.find (comm));
+        if (nextline.find (delim) != string::npos)
+          continue;
+        if (sentry != ""  &&  nextline.find (sentry) != string::npos)
+          continue;
+
+        nlcopy = nextline;
+        ConfigFile::trim (nlcopy);
+        if (nlcopy != "") line += "\n";
+        line += nextline;
+        terminate = false;
+      }
+
+      // Store key and value
+      ConfigFile::trim (key);
+      ConfigFile::trim (line);
+      cf.myContents[key] = line;  // overwrites if key is repeated
+    }
+  }
+
+  return is;
+}
diff --git a/src/libprojectM/ConfigFile.h b/src/libprojectM/ConfigFile.h
index c2f0024..7e93ae4 100644
--- a/src/libprojectM/ConfigFile.h
+++ b/src/libprojectM/ConfigFile.h
@@ -1,253 +1,258 @@
-// ConfigFile.h

-// Class for reading named values from configuration files

-// Richard J. Wagner  v2.1  24 May 2004  wagnerr@umich.edu

-

-// Copyright (c) 2004 Richard J. Wagner

-// 

-// Permission is hereby granted, free of charge, to any person obtaining a copy

-// of this software and associated documentation files (the "Software"), to

-// deal in the Software without restriction, including without limitation the

-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or

-// sell copies of the Software, and to permit persons to whom the Software is

-// furnished to do so, subject to the following conditions:

-// 

-// The above copyright notice and this permission notice shall be included in

-// all copies or substantial portions of the Software.

-// 

-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS

-// IN THE SOFTWARE.

-

-// Typical usage

-// -------------

-// 

-// Given a configuration file "settings.inp":

-//   atoms  = 25

-//   length = 8.0  # nanometers

-//   name = Reece Surcher

-// 

-// Named values are read in various ways, with or without default values:

-//   ConfigFile config( "settings.inp" );

-//   int atoms = config.read<int>( "atoms" );

-//   double length = config.read( "length", 10.0 );

-//   string author, title;

-//   config.readInto( author, "name" );

-//   config.readInto( title, "title", string("Untitled") );

-// 

-// See file example.cpp for more examples.

-

-#ifndef CONFIGFILE_H

-#define CONFIGFILE_H

-

-#include <string>

-#include <map>

-#include <iostream>

-#include <fstream>

-#include <sstream>

-

-using std::string;

-

-class ConfigFile {

-// Data

-protected:

-	string myDelimiter;  // separator between key and value

-	string myComment;    // separator between value and comments

-	string mySentry;     // optional string to signal end of file

-	std::map<string,string> myContents;  // extracted keys and values

-	

-	typedef std::map<string,string>::iterator mapi;

-	typedef std::map<string,string>::const_iterator mapci;

-

-// Methods

-public:

-	ConfigFile( string filename,

-	            string delimiter = "=",

-	            string comment = "#",

-				string sentry = "EndConfigFile" );

-	ConfigFile();

-	

-	// Search for key and read value or optional default value

-	template<class T> T read( const string& key ) const;  // call as read<T>

-	template<class T> T read( const string& key, const T& value ) const;

-	template<class T> bool readInto( T& var, const string& key ) const;

-	template<class T>

-	bool readInto( T& var, const string& key, const T& value ) const;

-	

-	// Modify keys and values

-	template<class T> void add( string key, const T& value );

-	void remove( const string& key );

-	

-	// Check whether key exists in configuration

-	bool keyExists( const string& key ) const;

-	

-	// Check or change configuration syntax

-	string getDelimiter() const { return myDelimiter; }

-	string getComment() const { return myComment; }

-	string getSentry() const { return mySentry; }

-	string setDelimiter( const string& s )

-		{ string old = myDelimiter;  myDelimiter = s;  return old; }  

-	string setComment( const string& s )

-		{ string old = myComment;  myComment = s;  return old; }

-	

-	// Write or read configuration

-	friend std::ostream& operator<<( std::ostream& os, const ConfigFile& cf );

-	friend std::istream& operator>>( std::istream& is, ConfigFile& cf );

-	

-protected:

-	template<class T> static string T_as_string( const T& t );

-	template<class T> static T string_as_T( const string& s );

-	static void trim( string& s );

-

-

-// Exception types

-public:

-	struct file_not_found {

-		string filename;

-		file_not_found( const string& filename_ = string() )

-			: filename(filename_) {} };

-	struct key_not_found {  // thrown only by T read(key) variant of read()

-		string key;

-		key_not_found( const string& key_ = string() )

-			: key(key_) {} };

-};

-

-

-/* static */

-template<class T>

-string ConfigFile::T_as_string( const T& t )

-{

-	// Convert from a T to a string

-	// Type T must support << operator

-	std::ostringstream ost;

-	ost << t;

-	return ost.str();

-}

-

-

-/* static */

-template<class T>

-T ConfigFile::string_as_T( const string& s )

-{

-	// Convert from a string to a T

-	// Type T must support >> operator

-	T t;

-	std::istringstream ist(s);

-	ist >> t;

-	return t;

-}

-

-

-/* static */

-template<>

-inline string ConfigFile::string_as_T<string>( const string& s )

-{

-	// Convert from a string to a string

-	// In other words, do nothing

-	return s;

-}

-

-

-/* static */

-template<>

-inline bool ConfigFile::string_as_T<bool>( const string& s )

-{

-	// Convert from a string to a bool

-	// Interpret "false", "F", "no", "n", "0" as false

-	// Interpret "true", "T", "yes", "y", "1", "-1", or anything else as true

-	bool b = true;

-	string sup = s;

-	for( string::iterator p = sup.begin(); p != sup.end(); ++p )

-		*p = toupper(*p);  // make string all caps

-	if( sup==string("FALSE") || sup==string("F") ||

-	    sup==string("NO") || sup==string("N") ||

-	    sup==string("0") || sup==string("NONE") )

-		b = false;

-	return b;

-}

-

-

-template<class T>

-T ConfigFile::read( const string& key ) const

-{

-	// Read the value corresponding to key

-	mapci p = myContents.find(key);

-	if( p == myContents.end() ) throw key_not_found(key);

-	return string_as_T<T>( p->second );

-}

-

-

-template<class T>

-T ConfigFile::read( const string& key, const T& value ) const

-{

-	// Return the value corresponding to key or given default value

-	// if key is not found

-	mapci p = myContents.find(key);

-	if( p == myContents.end() ) return value;

-	return string_as_T<T>( p->second );

-}

-

-

-template<class T>

-bool ConfigFile::readInto( T& var, const string& key ) const

-{

-	// Get the value corresponding to key and store in var

-	// Return true if key is found

-	// Otherwise leave var untouched

-	mapci p = myContents.find(key);

-	bool found = ( p != myContents.end() );

-	if( found ) var = string_as_T<T>( p->second );

-	return found;

-}

-

-

-template<class T>

-bool ConfigFile::readInto( T& var, const string& key, const T& value ) const

-{

-	// Get the value corresponding to key and store in var

-	// Return true if key is found

-	// Otherwise set var to given default

-	mapci p = myContents.find(key);

-	bool found = ( p != myContents.end() );

-	if( found )

-		var = string_as_T<T>( p->second );

-	else

-		var = value;

-	return found;

-}

-

-

-template<class T>

-void ConfigFile::add( string key, const T& value )

-{

-	// Add a key with given value

-	string v = T_as_string( value );

-	trim(key);

-	trim(v);

-	myContents[key] = v;

-	return;

-}

-

-#endif  // CONFIGFILE_H

-

-// Release notes:

-// v1.0  21 May 1999

-//   + First release

-//   + Template read() access only through non-member readConfigFile()

-//   + ConfigurationFileBool is only built-in helper class

-// 

-// v2.0  3 May 2002

-//   + Shortened name from ConfigurationFile to ConfigFile

-//   + Implemented template member functions

-//   + Changed default comment separator from % to #

-//   + Enabled reading of multiple-line values

-// 

-// v2.1  24 May 2004

-//   + Made template specializations inline to avoid compiler-dependent linkage

-//   + Allowed comments within multiple-line values

-//   + Enabled blank line termination for multiple-line values

-//   + Added optional sentry to detect end of configuration file

-//   + Rewrote messy trimWhitespace() function as elegant trim()

+// ConfigFile.h
+// Class for reading named values from configuration files
+// Richard J. Wagner  v2.1  24 May 2004  wagnerr@umich.edu
+
+// Copyright (c) 2004 Richard J. Wagner
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+
+// Typical usage
+// -------------
+//
+// Given a configuration file "settings.inp":
+//   atoms  = 25
+//   length = 8.0  # nanometers
+//   name = Reece Surcher
+//
+// Named values are read in various ways, with or without default values:
+//   ConfigFile config ("settings.inp");
+//   int atoms = config.read<int>( "atoms");
+//   double length = config.read ("length", 10.0);
+//   string author, title;
+//   config.readInto (author, "name");
+//   config.readInto (title, "title", string("Untitled"));
+//
+// See file example.cpp for more examples.
+
+#ifndef CONFIGFILE_H
+#define CONFIGFILE_H
+
+#include <string>
+#include <map>
+#include <iostream>
+#include <fstream>
+#include <sstream>
+
+using std::string;
+
+class ConfigFile {
+// Data
+protected:
+  string                  myDelimiter;  // separator between key and value
+  string                  myComment;    // separator between value and comments
+  string                  mySentry;     // optional string to signal end of file
+  std::map<string,string> myContents;   // extracted keys and values
+
+  typedef std::map<string,string>::iterator mapi;
+  typedef std::map<string,string>::const_iterator mapci;
+
+// Methods
+public:
+  ConfigFile (string filename,
+              string delimiter = "=",
+              string comment = "#",
+              string sentry = "EndConfigFile");
+  ConfigFile();
+
+  // Search for key and read value or optional default value
+  template<class T> T     read (const string& key) const;  // call as read<T>
+  template<class T> T     read (const string& key, const T& value) const;
+  template<class T> bool  readInto (T& var, const string& key) const;
+  template<class T> bool  readInto (T& var, const string& key, const T& value) const;
+
+  // Modify keys and values
+  template<class T> void  add (string key, const T& value);
+  void                    remove (const string& key);
+
+  // Check whether key exists in configuration
+  bool keyExists (const string& key) const;
+
+  // Check or change configuration syntax
+  string getDelimiter() const { return myDelimiter; }
+  string getComment() const { return myComment; }
+  string getSentry() const { return mySentry; }
+  string setDelimiter (const string& s)
+    { string old = myDelimiter;  myDelimiter = s;  return old; }
+  string setComment (const string& s)
+    { string old = myComment;  myComment = s;  return old; }
+
+  // Write or read configuration
+  friend std::ostream& operator<<(std::ostream& os, const ConfigFile& cf);
+  friend std::istream& operator>>(std::istream& is, ConfigFile& cf);
+
+protected:
+  template<class T> static string T_as_string (const T& t);
+  template<class T> static T      string_as_T (const string& s);
+  static void                     trim (string& s);
+
+
+// Exception types
+public:
+  struct file_not_found {
+    string filename;
+    file_not_found (const string& filename_ = string())
+      : filename(filename_) {} };
+  struct key_not_found {  // thrown only by T read(key) variant of read()
+    string key;
+    key_not_found (const string& key_ = string())
+      : key(key_) {} };
+};
+
+
+/* static */
+template<class T>
+string ConfigFile::T_as_string (const T& t)
+{
+  // Convert from a T to a string
+  // Type T must support << operator
+  std::ostringstream ost;
+
+  ost << t;
+  return ost.str();
+}
+
+
+/* static */
+template<class T>
+T ConfigFile::string_as_T (const string& s)
+{
+  // Convert from a string to a T
+  // Type T must support >> operator
+  T t;
+  std::istringstream ist (s);
+
+  ist >> t;
+  return t;
+}
+
+
+/* static */
+template<>
+inline string ConfigFile::string_as_T<string>(const string& s)
+{
+  // Convert from a string to a string
+  // In other words, do nothing
+  return s;
+}
+
+
+/* static */
+template<>
+inline bool ConfigFile::string_as_T<bool>(const string& s)
+{
+  // Convert from a string to a bool
+  // Interpret "false", "F", "no", "n", "0" as false
+  // Interpret "true", "T", "yes", "y", "1", "-1", or anything else as true
+  bool b = true;
+  string sup = s;
+
+  for (string::iterator p = sup.begin();  p != sup.end();  ++p)
+    *p = toupper (*p);  // make string all caps
+  if (    sup==string ("FALSE")  ||  sup==string ("F")
+      ||  sup==string ("NO")  ||  sup==string ("N")
+      ||  sup==string ("0")  ||  sup==string ("NONE"))
+    b = false;
+  return b;
+}
+
+
+template<class T>
+T ConfigFile::read (const string& key) const
+{
+  // Read the value corresponding to key
+  mapci p = myContents.find (key);
+  if (p == myContents.end()) throw key_not_found (key);
+  return string_as_T<T>(p->second);
+}
+
+
+template<class T>
+T ConfigFile::read (const string& key, const T& value) const
+{
+  // Return the value corresponding to key or given default value
+  // if key is not found
+  mapci p = myContents.find (key);
+  if (p == myContents.end()) return value;
+  return string_as_T<T>(p->second);
+}
+
+
+template<class T>
+bool ConfigFile::readInto (T& var, const string& key) const
+{
+  // Get the value corresponding to key and store in var
+  // Return true if key is found
+  // Otherwise leave var untouched
+  mapci p = myContents.find (key);
+  bool found = (p != myContents.end());
+
+  if (found) var = string_as_T<T>(p->second);
+  return found;
+}
+
+
+template<class T>
+bool ConfigFile::readInto (T& var, const string& key, const T& value) const
+{
+  // Get the value corresponding to key and store in var
+  // Return true if key is found
+  // Otherwise set var to given default
+  mapci p = myContents.find (key);
+  bool found = (p != myContents.end());
+
+  if (found)
+    var = string_as_T<T>(p->second);
+  else
+    var = value;
+  return found;
+}
+
+
+template<class T>
+void ConfigFile::add (string key, const T& value)
+{
+  // Add a key with given value
+  string v = T_as_string (value);
+
+  trim (key);
+  trim (v);
+  myContents[key] = v;
+  return;
+}
+
+#endif  // CONFIGFILE_H
+
+// Release notes:
+// v1.0  21 May 1999
+//   + First release
+//   + Template read() access only through non-member readConfigFile()
+//   + ConfigurationFileBool is only built-in helper class
+//
+// v2.0  3 May 2002
+//   + Shortened name from ConfigurationFile to ConfigFile
+//   + Implemented template member functions
+//   + Changed default comment separator from % to #
+//   + Enabled reading of multiple-line values
+//
+// v2.1  24 May 2004
+//   + Made template specializations inline to avoid compiler-dependent linkage
+//   + Allowed comments within multiple-line values
+//   + Enabled blank line termination for multiple-line values
+//   + Added optional sentry to detect end of configuration file
+//   + Rewrote messy trimWhitespace() function as elegant trim()
diff --git a/src/libprojectM/HungarianMethod.hpp b/src/libprojectM/HungarianMethod.hpp
index 4b6b93c..e68f5d8 100644
--- a/src/libprojectM/HungarianMethod.hpp
+++ b/src/libprojectM/HungarianMethod.hpp
@@ -1,11 +1,13 @@
 #ifndef HUNGARIAN_METHOD_HPP
 #define HUNGARIAN_METHOD_HPP
+//
 //#include "Common.hpp"
 #include <cstdlib>
 #include <cstdio>
 #include <cstring>
 #include <limits>
 
+
 /// A function object which calculates the maximum-weighted bipartite matching between
 /// two sets via the hungarian method.
 template <int N=20>
@@ -14,15 +16,15 @@
 static const int MAX_SIZE = N;
 
 private:
-int n, max_match;        //n workers and n jobs
-double lx[N], ly[N];        //labels of X and Y parts
-int xy[N];               //xy[x] - vertex that is matched with x,
-int yx[N];               //yx[y] - vertex that is matched with y
-bool S[N], T[N];         //sets S and T in algorithm
-double slack[N];            //as in the algorithm description
-double slackx[N];           //slackx[y] such a vertex, that
-                         // l(slackx[y]) + l(y) - w(slackx[y],y) = slack[y]
-int prev[N];             //array for memorizing alternating paths
+int     n, max_match;       // n workers and n jobs
+double  lx[N], ly[N];       // labels of X and Y parts
+int     xy[N];              // xy[x] - vertex that is matched with x,
+int     yx[N];              // yx[y] - vertex that is matched with y
+bool    S[N], T[N];         // sets S and T in algorithm
+double  slack[N];           // as in the algorithm description
+double  slackx[N];          // slackx[y] such a vertex, that
+                            //  l(slackx[y]) + l(y) - w(slackx[y],y) = slack[y]
+int     prev[N];            // array for memorizing alternating paths
 
 void init_labels(const double cost[N][N])
 {
@@ -56,7 +58,7 @@
         slack[y] = lx[root] + ly[y] - cost[root][y];
         slackx[y] = root;
     }
-   while (true)                                                        //main cycle
+    while (true)                                                        //main cycle
     {
         while (rd < wr)                                                 //building tree with bfs cycle
         {
@@ -174,7 +176,7 @@
 /// \param i the index of the ith element in the first set (passed in operator())
 /// \returns an index j, denoting the matched jth element of the 2nd set
 inline int matching(int i) const {
-	return xy[i];
+  return xy[i];
 }
 
 
@@ -183,7 +185,7 @@
 /// \returns an index i, denoting the matched ith element of the 1st set
 /// \note inverseMatching(matching(i)) == i
 inline int inverseMatching(int j) const {
-	return yx[j];
+  return yx[j];
 }
 
 };
diff --git a/src/libprojectM/KeyHandler.cpp b/src/libprojectM/KeyHandler.cpp
index 3661f2b..5ff80a4 100644
--- a/src/libprojectM/KeyHandler.cpp
+++ b/src/libprojectM/KeyHandler.cpp
@@ -18,7 +18,6 @@
  * See 'LICENSE.txt' included within this release
  *
  */
-
 #include <stdio.h>
 
 #include "Common.hpp"
@@ -34,17 +33,19 @@
 #include "TimeKeeper.hpp"
 
 
+void selectRandom (const bool hardCut);
+void selectNext (const bool hardCut);
+void selectPrevious (const bool hardCut);
+
+
 class Preset;
 interface_t current_interface = DEFAULT_INTERFACE;
 
-void selectRandom(const bool hardCut);
-void selectNext(const bool hardCut);
-void selectPrevious(const bool hardCut);
 
-void refreshConsole() {
-
+void
+refreshConsole ()
+{
   switch (current_interface) {
-
   case MENU_INTERFACE:
     // unimplemented
     break;
@@ -62,192 +63,223 @@
   default:
     break;
   }
-
 }
 
-void projectM::key_handler( projectMEvent event,
-                            projectMKeycode keycode, projectMModifier modifier ) {
+void
+projectM::key_handler (
+projectMEvent     event,
+projectMKeycode   keycode,
+projectMModifier  modifier
+)
+{
+  switch (event) {
+  case PROJECTM_KEYDOWN:
 
-	switch( event ) {
+    //default_key_handler ();
+    switch (current_interface) {
+    case MENU_INTERFACE:
+//    menu_key_handler (this, event, keycode);
+      break;
 
+    case SHELL_INTERFACE:
+//    shell_key_handler ();
+      break;
 
-	case PROJECTM_KEYDOWN:
+    case EDITOR_INTERFACE:
+//    editor_key_handler (event,keycode);
+      break;
 
-	  //default_key_handler();
-	  switch (current_interface)
-	    {
+    case BROWSER_INTERFACE:
+//    browser_key_handler (event,keycode,modifier);
+      break;
 
-	    case MENU_INTERFACE:
-//	      menu_key_handler(this, event, keycode);
-	      break;
-	    case SHELL_INTERFACE:
-	      //shell_key_handler();
-	      break;
-	    case EDITOR_INTERFACE:
-//	      editor_key_handler(event,keycode);
-	      break;
-	    case BROWSER_INTERFACE:
-//	      browser_key_handler(event,keycode,modifier);
-	      break;
-	    case DEFAULT_INTERFACE:
-	      default_key_handler(event,keycode);
-	      break;
-	    default:
-	      default_key_handler(event,keycode);
-	      break;
+    case DEFAULT_INTERFACE:
+      default_key_handler (event, keycode);
+      break;
 
-	    }
-	  break;
-	default:
-		break;
+    default:
+      default_key_handler (event, keycode);
+      break;
+    }
+    break;
 
-	}
+  default:
+    break;
+  }
 }
 
-void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode) {
+void
+projectM::default_key_handler (projectMEvent event, projectMKeycode keycode)
+{
+  switch (event) {
 
-	switch( event ) {
+  case PROJECTM_KEYDOWN:
 
-	case PROJECTM_KEYDOWN:
+    switch (keycode) {
+    case PROJECTM_K_UP:
+      beatDetect->beat_sensitivity += 0.25;
+      if (beatDetect->beat_sensitivity > 5.0) beatDetect->beat_sensitivity = 5.0;
+      break;
 
-	  switch( keycode )
-	    {
-	    case PROJECTM_K_UP:
-            beatDetect->beat_sensitivity += 0.25;
-			if (beatDetect->beat_sensitivity > 5.0) beatDetect->beat_sensitivity = 5.0;
-	      break;
-	    case PROJECTM_K_DOWN:
-            beatDetect->beat_sensitivity -= 0.25;
-			if (beatDetect->beat_sensitivity < 0) beatDetect->beat_sensitivity = 0;
-	      break;
-		case PROJECTM_K_h:
- 		  renderer->showhelp = !renderer->showhelp;
-	      renderer->showstats= false;
-	      renderer->showfps=false;
-	    case PROJECTM_K_F1:
-	      renderer->showhelp = !renderer->showhelp;
-	      renderer->showstats=false;
-	      renderer->showfps=false;
-	      break;
-	    case PROJECTM_K_y:
-		this->setShuffleEnabled(!this->isShuffleEnabled());
-		 break;
+    case PROJECTM_K_DOWN:
+      beatDetect->beat_sensitivity -= 0.25;
+      if (beatDetect->beat_sensitivity < 0) beatDetect->beat_sensitivity = 0;
+      break;
 
-	    case PROJECTM_K_F5:
-	      if (!renderer->showhelp)
-		      renderer->showfps = !renderer->showfps;
-	      break;
-	    case PROJECTM_K_F4:
-		if (!renderer->showhelp)
-	       		renderer->showstats = !renderer->showstats;
-	      break;
-	    case PROJECTM_K_F3: {
-	      renderer->showpreset = !renderer->showpreset;
-	      break;
-	     }
-	    case PROJECTM_K_F2:
-	      renderer->showtitle = !renderer->showtitle;
-	      break;
+    case PROJECTM_K_h:
+      renderer->showhelp  = !renderer->showhelp;
+      renderer->showstats = false;
+      renderer->showfps   = false;
+      /*  FIXME: should be 'break' here or folded into following case.  */
+
+    case PROJECTM_K_F1:
+      renderer->showhelp  = !renderer->showhelp;
+      renderer->showstats = false;
+      renderer->showfps   = false;
+      break;
+
+    case PROJECTM_K_y:
+      this->setShuffleEnabled (!this->isShuffleEnabled());
+      break;
+
+    case PROJECTM_K_F5:
+      if (!renderer->showhelp)
+        renderer->showfps = !renderer->showfps;
+      break;
+
+    case PROJECTM_K_F4:
+      if (!renderer->showhelp)
+        renderer->showstats = !renderer->showstats;
+      break;
+
+    case PROJECTM_K_F3:
+     {
+      renderer->showpreset = !renderer->showpreset;
+      break;
+     }
+
+    case PROJECTM_K_F2:
+      renderer->showtitle = !renderer->showtitle;
+      break;
 #ifndef MACOS
-	    case PROJECTM_K_F9:
+    case PROJECTM_K_F9:
 #else
-        case PROJECTM_K_F8:
+    case PROJECTM_K_F8:
 #endif
 
-	      renderer->studio = !renderer->studio;
-	      break;
+      renderer->studio = !renderer->studio;
+      break;
 
-	    case PROJECTM_K_ESCAPE: {
-//	        exit( 1 );
-	        break;
-	      }
-	    case PROJECTM_K_f:
+    case PROJECTM_K_ESCAPE:
+     {
+      //          exit (1);
+      break;
+     }
 
-	      break;
-	    case PROJECTM_K_a:
-		    renderer->correction = !renderer->correction;
-	        break;
-	    case PROJECTM_K_b:
-	      break;
-            case PROJECTM_K_n:
-		selectNext(true);
-	      break;
-            case PROJECTM_K_N:
-		selectNext(false);
-	      break;
-	    case PROJECTM_K_r:
-		selectRandom(true);
-		break;
-	    case PROJECTM_K_R:
-		selectRandom(false);
-		break;
-	    case PROJECTM_K_p:
-	      selectPrevious(true);
-	      break;
-	    case PROJECTM_K_P:
-	      selectPrevious(false);
-	      break;
-	    case PROJECTM_K_l:
-		renderer->noSwitch=!renderer->noSwitch;
-	      break;
-	    case PROJECTM_K_s:
-            	renderer->studio = !renderer->studio;
-	    case PROJECTM_K_i:
-	        break;
-	    case PROJECTM_K_z:
-	      break;
-	    case PROJECTM_K_0:
-//	      nWaveMode=0;
-	      break;
-	    case PROJECTM_K_6:
-//	      nWaveMode=6;
-	      break;
-	    case PROJECTM_K_7:
-//	      nWaveMode=7;
-	      break;
-	    case PROJECTM_K_m:
-	      break;
-	    case PROJECTM_K_t:
-	      break;
-	    case PROJECTM_K_EQUALS:
-	    case PROJECTM_K_PLUS:
+    case PROJECTM_K_f:
+      break;
 
-	    	unsigned int index;
+    case PROJECTM_K_a:
+      renderer->correction = !renderer->correction;
+      break;
 
-	    	if (selectedPresetIndex(index)) {
+    case PROJECTM_K_b:
+      break;
 
-	    		const int oldRating = getPresetRating(index, HARD_CUT_RATING_TYPE);
+    case PROJECTM_K_n:
+      selectNext (true);
+      break;
 
-	    		if (oldRating >= 6)
-	    			  break;
+    case PROJECTM_K_N:
+      selectNext (false);
+      break;
 
-	    		const int rating = oldRating + 1;
+    case PROJECTM_K_r:
+      selectRandom (true);
+      break;
 
-	    		changePresetRating(index, rating, HARD_CUT_RATING_TYPE);
-	    	}
+    case PROJECTM_K_R:
+      selectRandom (false);
+      break;
 
-	    	break;
+    case PROJECTM_K_p:
+      selectPrevious (true);
+      break;
 
-	    case PROJECTM_K_MINUS:
-	    	if (selectedPresetIndex(index)) {
+    case PROJECTM_K_P:
+      selectPrevious (false);
+      break;
 
-	    		const int oldRating = getPresetRating(index, HARD_CUT_RATING_TYPE);
+    case PROJECTM_K_l:
+      renderer->noSwitch=!renderer->noSwitch;
+      break;
 
-	    		if (oldRating <= 1)
-	    			  break;
+    case PROJECTM_K_s:
+      renderer->studio = !renderer->studio;
 
-	    		const int rating = oldRating - 1;
+    case PROJECTM_K_i:
+      break;
 
-	    		changePresetRating(index, rating, HARD_CUT_RATING_TYPE);
-	    	}
-	    	break;
+    case PROJECTM_K_z:
+      break;
 
-	    default:
-	      break;
-	    }
-	default:
-		break;
+    case PROJECTM_K_0:
+      //        nWaveMode=0;
+      break;
 
-	}
+    case PROJECTM_K_6:
+      //        nWaveMode=6;
+      break;
+
+    case PROJECTM_K_7:
+      //        nWaveMode=7;
+      break;
+
+    case PROJECTM_K_m:
+      break;
+
+    case PROJECTM_K_t:
+      break;
+
+    case PROJECTM_K_EQUALS:
+    case PROJECTM_K_PLUS:
+     {
+      unsigned int index;
+
+      if (selectedPresetIndex (index)) {
+        const int oldRating = getPresetRating (index, HARD_CUT_RATING_TYPE);
+
+        if (oldRating >= 6)
+          break;
+
+        const int rating = oldRating + 1;
+
+        changePresetRating (index, rating, HARD_CUT_RATING_TYPE);
+      }
+      break;
+     }
+
+    case PROJECTM_K_MINUS:
+     {
+      unsigned int index;
+
+      if (selectedPresetIndex (index)) {
+        const int oldRating = getPresetRating (index, HARD_CUT_RATING_TYPE);
+
+        if (oldRating <= 1)
+          break;
+
+        const int rating = oldRating - 1;
+
+        changePresetRating (index, rating, HARD_CUT_RATING_TYPE);
+      }
+      break;
+     }
+
+    default:
+      break;
+    }
+  default:
+    break;
+  }
 }
-
diff --git a/src/libprojectM/KeyHandler.hpp b/src/libprojectM/KeyHandler.hpp
index b9a7563..7143e56 100644
--- a/src/libprojectM/KeyHandler.hpp
+++ b/src/libprojectM/KeyHandler.hpp
@@ -1,39 +1,39 @@
-/**

- * projectM -- Milkdrop-esque visualisation SDK

- * Copyright (C)2003-2007 projectM Team

- *

- * This library is free software; you can redistribute it and/or

- * modify it under the terms of the GNU Lesser General Public

- * License as published by the Free Software Foundation; either

- * version 2.1 of the License, or (at your option) any later version.

- *

- * This library 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

- * Lesser General Public License for more details.

- *

- * You should have received a copy of the GNU Lesser General Public

- * License along with this library; if not, write to the Free Software

- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

- * See 'LICENSE.txt' included within this release

- *

- */

-/**

- * $Id: console_interface.h,v 1.1.1.1 2005/12/23 18:05:03 psperl Exp $

- *

- * $Log$

- */

-

-#ifndef _KEY_HANDLER_HPP

-#define _KEY_HANDLER_HPP

-

-#include "event.h"

-class projectM;

-void default_key_handler(projectM *PM, projectMEvent event, projectMKeycode keycode);

-void refreshConsole();

-#if defined(__CPLUSPLUS) && !defined(MACOS)

-extern "C" void key_handler(projectM *PM, projectMEvent event, projectMKeycode keycode, projectMModifier modifier );

-#else

-extern void key_handler(projectM *PM, projectMEvent event, projectMKeycode keycode, projectMModifier modifier );

-#endif

-#endif /** !_KEY_HANDLER_HPP */

+/**
+ * projectM -- Milkdrop-esque visualisation SDK
+ * Copyright (C)2003-2007 projectM Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * See 'LICENSE.txt' included within this release
+ *
+ */
+/**
+ * $Id: console_interface.h,v 1.1.1.1 2005/12/23 18:05:03 psperl Exp $
+ *
+ * $Log$
+ */
+
+#ifndef _KEY_HANDLER_HPP
+#define _KEY_HANDLER_HPP
+
+#include "event.h"
+class projectM;
+void default_key_handler(projectM *PM, projectMEvent event, projectMKeycode keycode);
+void refreshConsole();
+#if defined(__CPLUSPLUS) && !defined(MACOS)
+extern "C" void key_handler(projectM *PM, projectMEvent event, projectMKeycode keycode, projectMModifier modifier );
+#else
+extern void key_handler(projectM *PM, projectMEvent event, projectMKeycode keycode, projectMModifier modifier );
+#endif
+#endif /** !_KEY_HANDLER_HPP */
diff --git a/src/libprojectM/MilkdropPresetFactory/BuiltinFuncs.cpp b/src/libprojectM/MilkdropPresetFactory/BuiltinFuncs.cpp
index 9d5be25..0835f97 100644
--- a/src/libprojectM/MilkdropPresetFactory/BuiltinFuncs.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/BuiltinFuncs.cpp
@@ -1,8 +1,8 @@
 //
 // C++ Implementation: BuiltinFuncs
 //
-// Description: 
-//  
+// Description:
+//
 //
 // Author: Carmelo Piccione <carmelo.piccione@gmail.com>, (C) 2007
 //
@@ -19,97 +19,104 @@
 #include <iostream>
 #include "fatal.h"
 
+
 std::map<std::string, Func*> BuiltinFuncs::builtin_func_tree;
 
-int BuiltinFuncs::load_builtin_func(const std::string & name, float (*func_ptr)(float*), int num_args) {
-	
-  Func * func; 
-  int retval; 
+
+int
+BuiltinFuncs::load_builtin_func (
+const std::string & name,
+float             (*func_ptr)(float*),
+int               num_args
+)
+{
+  Func * func;
+  int retval;
 
   /* Create new function */
-  func = new Func(name, func_ptr, num_args);
+  func = new Func (name, func_ptr, num_args);
 
   if (func == 0)
     return PROJECTM_OUTOFMEM_ERROR;
 
-  retval = insert_func( func );
+  retval = insert_func (func);
 
   return retval;
-
 }
 
-Func * BuiltinFuncs::find_func(const std::string & name) {
-
-  std::map<std::string, Func*>::iterator pos = builtin_func_tree.find(name);
+Func *
+BuiltinFuncs::find_func (const std::string & name)
+{
+  std::map<std::string, Func*>::iterator pos = builtin_func_tree.find (name);
 
   // Case: function not found, return null
   if (pos == builtin_func_tree.end())
-	return 0;
+  return 0;
 
   // Case: function found, return a pointer to it
   return pos->second;
-
 }
 
-int BuiltinFuncs::load_all_builtin_func() {
-
-  if (load_builtin_func("int", FuncWrappers::int_wrapper, 1) < 0)
+int
+BuiltinFuncs::load_all_builtin_func()
+{
+  if (load_builtin_func ("int", FuncWrappers::int_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("abs", FuncWrappers::abs_wrapper, 1) < 0)
+  if (load_builtin_func ("abs", FuncWrappers::abs_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("sin", FuncWrappers::sin_wrapper, 1) < 0)
+  if (load_builtin_func ("sin", FuncWrappers::sin_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("cos", FuncWrappers::cos_wrapper, 1) < 0)
+  if (load_builtin_func ("cos", FuncWrappers::cos_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("tan", FuncWrappers::tan_wrapper, 1) < 0)
+  if (load_builtin_func ("tan", FuncWrappers::tan_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("asin", FuncWrappers::asin_wrapper, 1) < 0)
+  if (load_builtin_func ("asin", FuncWrappers::asin_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("acos", FuncWrappers::acos_wrapper, 1) < 0)
+  if (load_builtin_func ("acos", FuncWrappers::acos_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("atan", FuncWrappers::atan_wrapper, 1) < 0)
+  if (load_builtin_func ("atan", FuncWrappers::atan_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("sqr", FuncWrappers::sqr_wrapper, 1) < 0)
+  if (load_builtin_func ("sqr", FuncWrappers::sqr_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("sqrt", FuncWrappers::sqrt_wrapper, 1) < 0)
+  if (load_builtin_func ("sqrt", FuncWrappers::sqrt_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("pow", FuncWrappers::pow_wrapper, 2) < 0)
+  if (load_builtin_func ("pow", FuncWrappers::pow_wrapper, 2) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("exp", FuncWrappers::exp_wrapper, 1) < 0)
+  if (load_builtin_func ("exp", FuncWrappers::exp_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("log", FuncWrappers::log_wrapper, 1) < 0)
+  if (load_builtin_func ("log", FuncWrappers::log_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("log10", FuncWrappers::log10_wrapper, 1) < 0)
+  if (load_builtin_func ("log10", FuncWrappers::log10_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("sign", FuncWrappers::sign_wrapper, 1) < 0)
+  if (load_builtin_func ("sign", FuncWrappers::sign_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("min", FuncWrappers::min_wrapper, 2) < 0)
+  if (load_builtin_func ("min", FuncWrappers::min_wrapper, 2) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("max", FuncWrappers::max_wrapper, 2) < 0)
+  if (load_builtin_func ("max", FuncWrappers::max_wrapper, 2) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("sigmoid", FuncWrappers::sigmoid_wrapper, 2) < 0)
+  if (load_builtin_func ("sigmoid", FuncWrappers::sigmoid_wrapper, 2) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("atan2", FuncWrappers::atan2_wrapper, 2) < 0)
+  if (load_builtin_func ("atan2", FuncWrappers::atan2_wrapper, 2) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("rand", FuncWrappers::rand_wrapper, 1) < 0)
+  if (load_builtin_func ("rand", FuncWrappers::rand_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("band", FuncWrappers::band_wrapper, 2) < 0)
+  if (load_builtin_func ("band", FuncWrappers::band_wrapper, 2) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("bor", FuncWrappers::bor_wrapper, 2) < 0)
+  if (load_builtin_func ("bor", FuncWrappers::bor_wrapper, 2) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("bnot", FuncWrappers::bnot_wrapper, 1) < 0)
+  if (load_builtin_func ("bnot", FuncWrappers::bnot_wrapper, 1) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("if", FuncWrappers::if_wrapper, 3) < 0)
+  if (load_builtin_func ("if", FuncWrappers::if_wrapper, 3) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("equal", FuncWrappers::equal_wrapper, 2) < 0)
+  if (load_builtin_func ("equal", FuncWrappers::equal_wrapper, 2) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("above", FuncWrappers::above_wrapper, 2) < 0)
+  if (load_builtin_func ("above", FuncWrappers::above_wrapper, 2) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("below", FuncWrappers::below_wrapper, 2) < 0)
+  if (load_builtin_func ("below", FuncWrappers::below_wrapper, 2) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("nchoosek", FuncWrappers::nchoosek_wrapper, 2) < 0)
+  if (load_builtin_func ("nchoosek", FuncWrappers::nchoosek_wrapper, 2) < 0)
     return PROJECTM_ERROR;
-  if (load_builtin_func("fact", FuncWrappers::fact_wrapper, 1) < 0)
+  if (load_builtin_func ("fact", FuncWrappers::fact_wrapper, 1) < 0)
     return PROJECTM_ERROR;
   if (load_builtin_func("print", FuncWrappers::print_wrapper, 1) < 0)
       return PROJECTM_ERROR;
@@ -120,14 +127,16 @@
 
 /* Initialize the builtin function database.
    Should only be necessary once */
-int BuiltinFuncs::init_builtin_func_db() {
+int
+BuiltinFuncs::init_builtin_func_db()
+{
   int retval;
 
   if (initialized) {
     return 0;
   } else
     initialized = true;
-  
+
   retval = load_all_builtin_func();
   return retval;
 }
@@ -136,40 +145,40 @@
 
 /* Destroy the builtin function database.
    Generally, do this on projectm exit */
-int BuiltinFuncs::destroy_builtin_func_db() {
+int
+BuiltinFuncs::destroy_builtin_func_db()
+{
+  traverse<TraverseFunctors::Delete<Func> >(builtin_func_tree);
 
-traverse<TraverseFunctors::Delete<Func> >(builtin_func_tree);
-
-builtin_func_tree.clear();
-initialized = false;
-return PROJECTM_SUCCESS;
+  builtin_func_tree.clear();
+  initialized = false;
+  return PROJECTM_SUCCESS;
 }
 
 /* Insert a function into the database */
-int BuiltinFuncs::insert_func( Func *func ) {
+int
+BuiltinFuncs::insert_func (Func *func)
+{
+  assert (func);
 
-  assert(func);
-  
   if (func == 0) {
-      std::cerr << "Received a null function object, ignoring...." << std::endl;
-      return PROJECTM_ERROR;
+    std::cerr << "Received a null function object, ignoring...." << std::endl;
+    return PROJECTM_ERROR;
   }
-  
+
 //   //std::cout << "inserting function " << func->getName() << std::endl;
-  
-  const std::pair<std::string, Func*> pair = std::make_pair(std::string(func->getName()), func);
-  
-  assert(pair.second);
-  
+
+  const std::pair<std::string, Func*> pair = std::make_pair (std::string (func->getName()), func);
+
+  assert (pair.second);
+
   const std::pair<std::map<std::string, Func*>::iterator, bool> inserteePair =
-  	builtin_func_tree.insert(pair);
-  	
+    builtin_func_tree.insert (pair);
+
   if (!inserteePair.second) {
-	std::cerr << "Failed to insert builtin function \"" << func->getName() << "\" into collection! Bailing..." << std::endl;
-	abort();
+    std::cerr << "Failed to insert builtin function \"" << func->getName() << "\" into collection! Bailing..." << std::endl;
+    abort();
   }
 
   return PROJECTM_SUCCESS;
 }
-
-
diff --git a/src/libprojectM/MilkdropPresetFactory/BuiltinFuncs.hpp b/src/libprojectM/MilkdropPresetFactory/BuiltinFuncs.hpp
index 5ee1879..d74c166 100644
--- a/src/libprojectM/MilkdropPresetFactory/BuiltinFuncs.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/BuiltinFuncs.hpp
@@ -21,6 +21,7 @@
 
 #include "RandomNumberGenerators.hpp"
 
+
 /* Wrappers for all the builtin functions
    The arg_list pointer is a list of floats. Its
    size is equal to the number of arguments the parameter
@@ -33,219 +34,271 @@
 
 public:
 
-static inline float int_wrapper(float * arg_list) {
-
-return floor(arg_list[0]);
-
-}
-
-
-static inline float sqr_wrapper(float * arg_list) {
-	return pow(arg_list[0], 2);
-}
-
-
-static inline float sigmoid_wrapper(float * arg_list)
+static inline float
+int_wrapper(float * arg_list)
 {
-	const double t = (1+exp(-arg_list[0]*arg_list[1]));
-	return (fabs(t) > 0.00001) ? 1.0/t : 0;
-}
-
-static inline float sign_wrapper(float * arg_list) {
-
-return -arg_list[0];
-}
-
-static inline float min_wrapper(float * arg_list) {
-
-if (arg_list[0] > arg_list[1])
-return arg_list[1];
-
-return arg_list[0];
-}
-
-static inline float max_wrapper(float * arg_list) {
-
-if (arg_list[0] > arg_list[1])
-return arg_list[0];
-
-return arg_list[1];
+  return floor(arg_list[0]);
 }
 
 
-static inline float bor_wrapper(float * arg_list) {
-
-return (float)((int)arg_list[0] || (int)arg_list[1]);
-}
-
-static inline float band_wrapper(float * arg_list) {
-return (float)((int)arg_list[0] && (int)arg_list[1]);
-}
-
-static inline float bnot_wrapper(float * arg_list) {
-return (float)(!(int)arg_list[0]);
-}
-
-static inline float if_wrapper(float * arg_list) {
-
-	if ((int)arg_list[0] == 0)
-		return arg_list[2];
-	//std::cout <<"NOT ZERO: " << arg_list[0] << std::endl;
-	return arg_list[1];
-}
-
-
-static inline float rand_wrapper(float * arg_list) {
-float l=1;
-
-//  printf("RAND ARG:(%d)\n", (int)arg_list[0]);
-if ((int)arg_list[0] > 0)
-	l  = (float) RandomNumberGenerators::uniformInteger((int)arg_list[0]);
-
-return l;
-}
-
-static inline float equal_wrapper(float * arg_list) {
-	return (arg_list[0] == arg_list[1]);
-}
-
-
-static inline float above_wrapper(float * arg_list) {
-
-return (arg_list[0] > arg_list[1]);
-}
-
-
-static inline float below_wrapper(float * arg_list) {
-
-return (arg_list[0] < arg_list[1]);
-}
-
-static float sin_wrapper(float * arg_list) {
-	const float d = sinf(*arg_list);
-	return d;
-}
-
-
-static inline float cos_wrapper(float * arg_list) {
-return (cos (arg_list[0]));
-}
-
-static inline float tan_wrapper(float * arg_list) {
-return (tan(arg_list[0]));
-}
-
-static inline float asin_wrapper(float * arg_list) {
-return (asin (arg_list[0]));
-}
-
-static inline float acos_wrapper(float * arg_list) {
-return (acos (arg_list[0]));
-}
-
-static inline float atan_wrapper(float * arg_list) {
-return (atan (arg_list[0]));
-}
-
-static inline float atan2_wrapper(float * arg_list) {
-return (atan2 (arg_list[0], arg_list[1]));
-}
-
-static inline float pow_wrapper(float * arg_list) {
-return (pow (arg_list[0], arg_list[1]));
-}
-
-static inline float exp_wrapper(float * arg_list) {
-return (exp(arg_list[0]));
-}
-
-static inline float abs_wrapper(float * arg_list) {
-return (fabs(arg_list[0]));
-}
-
-static inline float log_wrapper(float* arg_list) {
-return (log (arg_list[0]));
-}
-
-static inline float log10_wrapper(float * arg_list) {
-return (log10 (arg_list[0]));
-}
-
-static inline float sqrt_wrapper(float * arg_list) {
-return (sqrt (arg_list[0]));
-}
-
-
-static inline float print_wrapper(float * arg_list) {
-
-	int len  = 1;
-	for (int i = 0; i < len; i++)
-	{
-		std::cout << arg_list[i];
-		if (i != (len-1))
-			std::cout << " ";
-	}
-
-	if (len > 0)
-		std::cout << std::endl;
-
-	if (len > 0)
-		return arg_list[0];
-	else
-		return 0;
-}
-
-static inline float nchoosek_wrapper(float * arg_list) {
-unsigned long cnm = 1UL;
-int i, f;
-int n, m;
-
-n = (int)arg_list[0];
-m = (int)arg_list[1];
-
-if (m*2 >n) m = n-m;
-for (i=1 ; i <= m; n--, i++)
+static inline float
+sqr_wrapper(float * arg_list)
 {
-if ((f=n) % i == 0)
-f   /= i;
-else  cnm /= i;
-cnm *= f;
-}
-return (float)cnm;
+  return pow(arg_list[0], 2);
 }
 
 
-static inline float fact_wrapper(float * arg_list) {
-
-
-int result = 1;
-
-int n = (int)arg_list[0];
-
-while (n > 1) {
-result = result * n;
-n--;
+static inline float
+sigmoid_wrapper(float * arg_list)
+{
+  const double t = (1+exp(-arg_list[0]*arg_list[1]));
+  return (fabs(t) > 0.00001) ? 1.0/t : 0;
 }
-return (float)result;
+
+static inline float
+sign_wrapper(float * arg_list)
+{
+  return -arg_list[0];
 }
-};
+
+static inline float
+min_wrapper(float * arg_list)
+{
+  if (arg_list[0] > arg_list[1])
+    return arg_list[1];
+
+  return arg_list[0];
+}
+
+static inline float
+max_wrapper(float * arg_list)
+{
+  if (arg_list[0] > arg_list[1])
+    return arg_list[0];
+
+  return arg_list[1];
+}
+
+
+static inline float
+bor_wrapper(float * arg_list)
+{
+  return (float)((int)arg_list[0] || (int)arg_list[1]);
+}
+
+static inline float
+band_wrapper(float * arg_list)
+{
+  return (float)((int)arg_list[0] && (int)arg_list[1]);
+}
+
+static inline float
+bnot_wrapper(float * arg_list)
+{
+  return (float)(!(int)arg_list[0]);
+}
+
+static inline float
+if_wrapper(float * arg_list)
+{
+  if ((int)arg_list[0] == 0)
+    return arg_list[2];
+  //std::cout <<"NOT ZERO: " << arg_list[0] << std::endl;
+  return arg_list[1];
+}
+
+
+static inline float
+rand_wrapper(float * arg_list)
+{
+  float l=1;
+
+  //  printf("RAND ARG:(%d)\n", (int)arg_list[0]);
+  if ((int)arg_list[0] > 0)
+    l  = (float) RandomNumberGenerators::uniformInteger((int)arg_list[0]);
+
+  return l;
+}
+
+static inline float
+equal_wrapper(float * arg_list)
+{
+  return (arg_list[0] == arg_list[1]);
+}
+
+
+static inline float
+above_wrapper(float * arg_list)
+{
+  return (arg_list[0] > arg_list[1]);
+}
+
+
+static inline float
+below_wrapper(float * arg_list)
+{
+  return (arg_list[0] < arg_list[1]);
+}
+
+static float
+sin_wrapper(float * arg_list)
+{
+  const float d = sinf(*arg_list);
+  return d;
+}
+
+
+static inline float
+cos_wrapper(float * arg_list)
+{
+  return (cos (arg_list[0]));
+}
+
+static inline float
+tan_wrapper(float * arg_list)
+{
+  return (tan(arg_list[0]));
+}
+
+static inline float
+asin_wrapper(float * arg_list)
+{
+  return (asin (arg_list[0]));
+}
+
+static inline float
+acos_wrapper(float * arg_list)
+{
+  return (acos (arg_list[0]));
+}
+
+static inline float
+atan_wrapper(float * arg_list)
+{
+  return (atan (arg_list[0]));
+}
+
+static inline float
+atan2_wrapper(float * arg_list)
+{
+  return (atan2 (arg_list[0], arg_list[1]));
+}
+
+static inline float
+pow_wrapper(float * arg_list)
+{
+  return (pow (arg_list[0], arg_list[1]));
+}
+
+static inline float
+exp_wrapper(float * arg_list)
+{
+  return (exp(arg_list[0]));
+}
+
+static inline float
+abs_wrapper(float * arg_list)
+{
+  return (fabs(arg_list[0]));
+}
+
+static inline float
+log_wrapper(float* arg_list)
+{
+  return (log (arg_list[0]));
+}
+
+static inline float
+log10_wrapper(float * arg_list)
+{
+  return (log10 (arg_list[0]));
+}
+
+static inline float
+sqrt_wrapper(float * arg_list)
+{
+  return (sqrt (arg_list[0]));
+}
+
+
+static inline float
+print_wrapper(float * arg_list)
+{
+  int len  = 1;
+
+  for (int i = 0;  i < len;  i++)
+  {
+    std::cout << arg_list[i];
+    if (i != (len - 1))
+      std::cout << " ";
+  }
+
+  if (len > 0)
+    std::cout << std::endl;
+
+  if (len > 0)
+    return arg_list[0];
+  else
+    return 0;
+}
+
+static inline float
+nchoosek_wrapper(float * arg_list)
+{
+  unsigned long cnm = 1UL;
+  int           i, f;
+  int           n, m;
+
+  n = (int)arg_list[0];
+  m = (int)arg_list[1];
+
+  if (m * 2 > n)
+    m = n - m;
+  for (i = 1;  i <= m;  n--, i++)
+  {
+    if ((f = n) % i == 0)
+      f   /= i;
+    else
+      cnm /= i;
+    cnm *= f;
+  }
+  return (float)cnm;
+}
+
+
+static inline float
+fact_wrapper(float * arg_list)
+{
+  int result = 1;
+
+  int n = (int)arg_list[0];
+
+  while (n > 1) {
+    result = result * n;
+    n--;
+  }
+  return (float)result;
+}
+
+};  /*  class FuncWrappers  */
 
 #include <map>
+
+
 class BuiltinFuncs {
-
 public:
-    
-    static int init_builtin_func_db();
-    static int destroy_builtin_func_db();
-    static int load_all_builtin_func();
-    static int load_builtin_func( const std::string & name, float (*func_ptr)(float*), int num_args );
+  static int  init_builtin_func_db();
+  static int  destroy_builtin_func_db();
+  static int  load_all_builtin_func();
+  static int  load_builtin_func( const std::string & name, float (*func_ptr)(float*), int num_args );
 
-    static int insert_func( Func *func );
-    static int remove_func( Func *func );
-    static Func *find_func( const std::string & name );
+  static int  insert_func( Func *func );
+  static int  remove_func( Func *func );
+  static Func *find_func( const std::string & name );
+
 private:
-     static std::map<std::string, Func*> builtin_func_tree;
-     static volatile bool initialized;
+  static std::map<std::string, Func*> builtin_func_tree;
+  static volatile bool                initialized;
 };
 
 #endif
diff --git a/src/libprojectM/MilkdropPresetFactory/BuiltinParams.cpp b/src/libprojectM/MilkdropPresetFactory/BuiltinParams.cpp
index e33149b..880caa7 100644
--- a/src/libprojectM/MilkdropPresetFactory/BuiltinParams.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/BuiltinParams.cpp
@@ -1,4 +1,3 @@
-
 #include "fatal.h"
 #include "BuiltinParams.hpp"
 #include <cassert>
@@ -9,18 +8,18 @@
 #include <stdio.h>
 #include "Common.hpp"
 
+
 BuiltinParams::BuiltinParams() {}
 
 BuiltinParams::BuiltinParams(PresetInputs & presetInputs, PresetOutputs & presetOutputs)
 {
-
   presetInputs.Initialize(presetOutputs.gx, presetOutputs.gy);
 
   int ret;
   if ((ret = init_builtin_param_db(presetInputs, presetOutputs)) != PROJECTM_SUCCESS)
   {
-	std::cout << "failed to allocate builtin parameter database with error " << ret << std::endl;;
-        throw ret;
+    std::cout << "failed to allocate builtin parameter database with error " << ret << std::endl;;
+    throw ret;
   }
 
 }
@@ -31,12 +30,20 @@
 }
 
 /* Loads a float parameter into the builtin database */
-int BuiltinParams::load_builtin_param_float(const std::string & name, void * engine_val, void * matrix, short int flags,
-    float init_val, float upper_bound, float lower_bound, const std::string & alt_name)
+int
+BuiltinParams::load_builtin_param_float (
+const std::string & name,
+void              * engine_val,
+void              * matrix,
+short int         flags,
+float             init_val,
+float             upper_bound,
+float             lower_bound,
+const std::string & alt_name
+)
 {
-
-  Param * param = NULL;
-  CValue iv, ub, lb;
+  Param   * param = NULL;
+  CValue  iv, ub, lb;
 
   iv.float_val = init_val;
   ub.float_val = upper_bound;
@@ -49,8 +56,9 @@
     fflush(stdout);
   }
 
-std::string lowerName(name);
-std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower);
+  std::string lowerName(name);
+
+  std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower);
 
   if ((param = new Param(lowerName, P_TYPE_DOUBLE, flags, engine_val, matrix, iv, ub, lb)) == NULL)
   {
@@ -82,6 +90,7 @@
   if (alt_name != "")
   {
     std::string alt_lower_name(alt_name);
+
     std::transform(alt_lower_name.begin(), alt_lower_name.end(), alt_lower_name.begin(), tolower);
     insert_param_alt_name(param,alt_lower_name);
 
@@ -90,8 +99,6 @@
       printf("alt_name inserted...");
       fflush(stdout);
     }
-
-
   }
 
   if (BUILTIN_PARAMS_DEBUG == 2) printf("finished\n");
@@ -104,18 +111,18 @@
 
 /* Destroy the builtin parameter database.
    Generally, do this on projectm exit */
-int BuiltinParams::destroy_builtin_param_db()
+int
+BuiltinParams::destroy_builtin_param_db()
 {
-
   traverse<TraverseFunctors::Delete<Param> >(builtin_param_tree);
   return PROJECTM_SUCCESS;
 }
 
 
 /* Insert a parameter into the database with an alternate name */
-int BuiltinParams::insert_param_alt_name(Param * param, const std::string & alt_name)
+int
+BuiltinParams::insert_param_alt_name(Param * param, const std::string & alt_name)
 {
-
   assert(param);
 
   aliasMap.insert(std::make_pair(alt_name, param->name));
@@ -123,45 +130,49 @@
   return PROJECTM_SUCCESS;
 }
 
-Param * BuiltinParams::find_builtin_param(const std::string & name)
+Param *
+BuiltinParams::find_builtin_param(const std::string & name)
 {
+  AliasMap::iterator  pos = aliasMap.find(name);
+  Param               * param = 0;
 
-
-
-  AliasMap::iterator pos = aliasMap.find(name);
-  Param * param = 0;
   //std::cerr << "[BuiltinParams] find_builtin_param: name is " << name << std::endl;
   if (pos == aliasMap.end())
   {
     std::map<std::string, Param*>::iterator builtinPos = builtin_param_tree.find(name);
 
     if (builtinPos != builtin_param_tree.end()) {
-    //  std::cerr << "[BuiltinParams] find_builtin_param: found it directly." << std::endl;
+      //  std::cerr << "[BuiltinParams] find_builtin_param: found it directly." << std::endl;
       param = builtinPos->second;
-     }
+    }
   }
   else
   {
-
     std::map<std::string, Param*>::iterator builtinPos = builtin_param_tree.find(pos->second);
 
     if (builtinPos != builtin_param_tree.end()) {
       //std::cerr << "[BuiltinParams] find_builtin_param: found it indirectly." << std::endl;
       param = builtinPos->second;
-
-}
+    }
   }
   return param;
 }
 
 
 /* Loads a integer parameter into the builtin database */
-int BuiltinParams::load_builtin_param_int(const std::string & name, void * engine_val, short int flags,
-    int init_val, int upper_bound, int lower_bound, const std::string &alt_name)
+int
+BuiltinParams::load_builtin_param_int (
+const std::string &name,
+void              *engine_val,
+short int         flags,
+int               init_val,
+int               upper_bound,
+int               lower_bound,
+const std::string &alt_name
+)
 {
-
-  Param * param;
-  CValue iv, ub, lb;
+  Param   * param;
+  CValue  iv, ub, lb;
 
   iv.int_val = init_val;
   ub.int_val = upper_bound;
@@ -169,6 +180,7 @@
 
   // normalize to lower case as milkdrop scripts depend on this
   std::string lowerName(name);
+
   std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower);
 
   param = new Param(lowerName, P_TYPE_INT, flags, engine_val, NULL, iv, ub, lb);
@@ -187,42 +199,52 @@
   if (alt_name != "")
   {
     std::string alt_lower_name(alt_name);
+
     std::transform(alt_lower_name.begin(), alt_lower_name.end(), alt_lower_name.begin(), tolower);
     insert_param_alt_name(param,alt_lower_name);
-
   }
 
   return PROJECTM_SUCCESS;
-
 }
 
-int BuiltinParams::load_builtin_param_string( const std::string & name, std::string * engine_val, short int flags) {
+int
+BuiltinParams::load_builtin_param_string (
+const std::string &name,
+std::string       *engine_val,
+short int         flags
+)
+{
+  /* Creates a new parameter of type string */
+  Param * param = Param::new_param_string(name.c_str(), flags, engine_val);
 
-	/* Creates a new parameter of type string */
-	Param * param = Param::new_param_string(name.c_str(), flags, engine_val);
-
-	if (insert_builtin_param( param ) < 0)
-	{
-		delete param;
-		return PROJECTM_ERROR;
-	}
-	return PROJECTM_SUCCESS;
+  if (insert_builtin_param( param ) < 0)
+  {
+    delete param;
+    return PROJECTM_ERROR;
+  }
+  return PROJECTM_SUCCESS;
 }
 
 /* Loads a boolean parameter */
-int BuiltinParams::load_builtin_param_bool(const std:: string & name, void * engine_val, short int flags,
-    int init_val, const std::string &alt_name)
+int
+BuiltinParams::load_builtin_param_bool (
+const std::string &name,
+void              *engine_val,
+short int         flags,
+int               init_val,
+const std::string &alt_name
+)
 {
-
-  Param * param;
-  CValue iv, ub, lb;
+  Param   * param;
+  CValue  iv, ub, lb;
 
   iv.int_val = init_val;
   ub.int_val = TRUE;
   lb.int_val = false;
 
-std::string lowerName(name);
-std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower);
+  std::string lowerName(name);
+
+  std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower);
 
   param = new Param(lowerName, P_TYPE_BOOL, flags, engine_val, NULL, iv, ub, lb);
 
@@ -240,16 +262,17 @@
   if (alt_name != "")
   {
     std::string alt_lower_name(alt_name);
+
     std::transform(alt_lower_name.begin(), alt_lower_name.end(), alt_lower_name.begin(), tolower);
     insert_param_alt_name(param,alt_lower_name);
   }
 
   return PROJECTM_SUCCESS;
-
 }
 
 /* Inserts a parameter into the builtin database */
-int BuiltinParams::insert_builtin_param( Param *param )
+int
+BuiltinParams::insert_builtin_param( Param *param )
 {
   std::pair<std::map<std::string, Param*>::iterator, bool> inserteePos = builtin_param_tree.insert(std::make_pair(param->name, param));
 
@@ -260,9 +283,12 @@
 
 /* Initialize the builtin parameter database.
    Should only be necessary once */
-int BuiltinParams::init_builtin_param_db(const PresetInputs & presetInputs, PresetOutputs & presetOutputs)
+int
+BuiltinParams::init_builtin_param_db (
+const PresetInputs  & presetInputs,
+PresetOutputs       & presetOutputs
+)
 {
-
   if (BUILTIN_PARAMS_DEBUG)
   {
     printf("init_builtin_param: loading database...");
@@ -273,7 +299,7 @@
   if (load_all_builtin_param(presetInputs, presetOutputs) < 0)
   {
     if (BUILTIN_PARAMS_DEBUG) printf("failed loading builtin parameters (FATAL)\n");
-    return PROJECTM_ERROR;
+      return PROJECTM_ERROR;
   }
 
   if (BUILTIN_PARAMS_DEBUG) printf("success!\n");
@@ -285,9 +311,12 @@
 
 
 /* Loads all builtin parameters, limits are also defined here */
-int BuiltinParams::load_all_builtin_param(const PresetInputs & presetInputs, PresetOutputs & presetOutputs)
+int
+BuiltinParams::load_all_builtin_param (
+const PresetInputs  & presetInputs,
+PresetOutputs       & presetOutputs
+)
 {
-
   load_builtin_param_float("frating", (void*)&presetOutputs.fRating, NULL, P_FLAG_NONE, 0.0 , 5.0, 0.0, "");
   load_builtin_param_float("fwavescale", (void*)&presetOutputs.wave.scale, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, "");
   load_builtin_param_float("gamma", (void*)&presetOutputs.fGammaAdj, NULL, P_FLAG_NONE, 0.0, MAX_DOUBLE_SIZE, 0, "fGammaAdj");
@@ -386,19 +415,25 @@
   load_builtin_param_int("fps", (void*)&presetInputs.fps, P_FLAG_READONLY, 15, MAX_INT_SIZE, 0, "");
 
   load_builtin_param_float("x", (void*)&presetInputs.x_per_pixel, presetInputs.origx,  P_FLAG_PER_PIXEL |P_FLAG_ALWAYS_MATRIX | P_FLAG_READONLY | P_FLAG_NONE,
-                           0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, "");
+  0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, "");
   load_builtin_param_float("y", (void*)&presetInputs.y_per_pixel, presetInputs.origy,  P_FLAG_PER_PIXEL |P_FLAG_ALWAYS_MATRIX |P_FLAG_READONLY | P_FLAG_NONE,
-                           0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, "");
+  0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, "");
   load_builtin_param_float("ang", (void*)&presetInputs.ang_per_pixel, presetInputs.origtheta,  P_FLAG_PER_PIXEL |P_FLAG_ALWAYS_MATRIX | P_FLAG_READONLY | P_FLAG_NONE,
-                           0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, "");
+  0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, "");
   load_builtin_param_float("rad", (void*)&presetInputs.rad_per_pixel, presetInputs.origrad,  P_FLAG_PER_PIXEL |P_FLAG_ALWAYS_MATRIX | P_FLAG_READONLY | P_FLAG_NONE,
-                           0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, "");
+  0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, "");
 
-  for (unsigned int i = 0; i < NUM_Q_VARIABLES;i++) {
-	std::ostringstream os;
-	os << "q" << i;
-	load_builtin_param_float(os.str().c_str(), (void*)&presetOutputs.q[i],  NULL, P_FLAG_PER_PIXEL |P_FLAG_QVAR, 0, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, "");
+  for (unsigned int i = 0;  i < NUM_Q_VARIABLES;  i++) {
+    std::ostringstream os;
 
+    os << "q" << i;
+    load_builtin_param_float (os.str().c_str(),
+                              (void*)&presetOutputs.q[i],
+                              NULL,
+                              P_FLAG_PER_PIXEL | P_FLAG_QVAR,
+                              0,
+                              MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE,
+                              "");
   }
 
   /* variables added in 1.04 */
@@ -406,6 +441,4 @@
   load_builtin_param_int("meshy", (void*)&presetInputs.gy, P_FLAG_READONLY, 24, 72, 6, "");
 
   return PROJECTM_SUCCESS;
-
 }
-
diff --git a/src/libprojectM/MilkdropPresetFactory/BuiltinParams.hpp b/src/libprojectM/MilkdropPresetFactory/BuiltinParams.hpp
index dbe60f1..3cf3f9d 100644
--- a/src/libprojectM/MilkdropPresetFactory/BuiltinParams.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/BuiltinParams.hpp
@@ -33,54 +33,56 @@
 #include <map>
 #include <cstdio>
 
+
 class BuiltinParams {
 
 public:
-   typedef std::map<std::string, std::string> AliasMap;
+  typedef std::map<std::string, std::string> AliasMap;
 
-    /** Default constructor leaves database in an uninitialized state.  */
-    BuiltinParams();
+  /** Default constructor leaves database in an uninitialized state.  */
+  BuiltinParams();
 
-    /** Construct a new builtin parameter database with variables references given by
-     * the preset input and output structures */
-     BuiltinParams(PresetInputs &  presetInputs, PresetOutputs & presetOutputs);
+  /** Construct a new builtin parameter database with variables references given by
+  * the preset input and output structures */
+  BuiltinParams(PresetInputs &  presetInputs, PresetOutputs & presetOutputs);
 
-    ~BuiltinParams();
+  ~BuiltinParams();
 
-    /** Param database initalizer / destructor functions */
-    int init_builtin_param_db(const PresetInputs & presetInputs, PresetOutputs & presetOutputs);
-    int load_all_builtin_param(const PresetInputs & presetInputs, PresetOutputs & presetOutputs);
-    int destroy_builtin_param_db();
+  /** Param database initalizer / destructor functions */
+  int init_builtin_param_db(const PresetInputs & presetInputs, PresetOutputs & presetOutputs);
+  int load_all_builtin_param(const PresetInputs & presetInputs, PresetOutputs & presetOutputs);
+  int destroy_builtin_param_db();
 
-    int insert_param_alt_name( Param *param, const std::string& salt_name );
-    Param *find_builtin_param( const std::string & name );
-    int load_builtin_param_float( const std::string & name, void *engine_val, void *matrix,
-                                  short int flags,
-                                  float init_val, float upper_bound,
-                                  float lower_bound, const std::string & alt_name );
-    int load_builtin_param_int( const std::string & name, void *engine_val, short int flags,
-                                int init_val, int upper_bound,
-                                int lower_bound, const std::string & alt_name );
-    int load_builtin_param_bool( const std::string & name, void *engine_val, short int flags,
-                                int init_val, const std::string & alt_name );
+  int insert_param_alt_name( Param *param, const std::string& salt_name );
+  Param *find_builtin_param( const std::string & name );
+  int load_builtin_param_float( const std::string & name, void *engine_val, void *matrix,
+                                short int flags,
+                                float init_val, float upper_bound,
+                                float lower_bound, const std::string & alt_name );
+  int load_builtin_param_int( const std::string & name, void *engine_val, short int flags,
+                              int init_val, int upper_bound,
+                              int lower_bound, const std::string & alt_name );
+  int load_builtin_param_bool( const std::string & name, void *engine_val, short int flags,
+                               int init_val, const std::string & alt_name );
 
-    int load_builtin_param_string( const std::string & name, std::string * engine_val, short int flags);
+  int load_builtin_param_string( const std::string & name, std::string * engine_val, short int flags);
 
-    int insert_builtin_param( Param *param );
+  int insert_builtin_param( Param *param );
 
-    template <class Fun>
-    void apply(Fun & fun) {
-	traverse(builtin_param_tree, fun);
-    }
+  template <class Fun>
+  void apply(Fun & fun) {
+    traverse(builtin_param_tree, fun);
+  }
 
 
 private:
-    static const bool BUILTIN_PARAMS_DEBUG = false;
+  static const bool BUILTIN_PARAMS_DEBUG = false;
 
-    // Used to associate multiple string names to one parameter
-    AliasMap aliasMap;
+  // Used to associate multiple string names to one parameter
+  AliasMap aliasMap;
 
-    // Internal datastructure to store the parameters
-    std::map<std::string,Param*> builtin_param_tree;
+  // Internal datastructure to store the parameters
+  std::map<std::string,Param*> builtin_param_tree;
 };
+
 #endif
diff --git a/src/libprojectM/MilkdropPresetFactory/CValue.hpp b/src/libprojectM/MilkdropPresetFactory/CValue.hpp
index 7c2f557..aa8eb5b 100644
--- a/src/libprojectM/MilkdropPresetFactory/CValue.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/CValue.hpp
@@ -30,9 +30,9 @@
 #define _CVALUE_H
 
 typedef union CValue_t {
-    bool bool_val;
-    int int_val;
-    float float_val;
-  } CValue;
+  bool  bool_val;
+  int   int_val;
+  float float_val;
+} CValue;
 
 #endif /** _CVALUE_H */
diff --git a/src/libprojectM/MilkdropPresetFactory/CustomShape.cpp b/src/libprojectM/MilkdropPresetFactory/CustomShape.cpp
index 4d2c283..5be0daa 100644
--- a/src/libprojectM/MilkdropPresetFactory/CustomShape.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/CustomShape.cpp
@@ -39,217 +39,216 @@
 
 CustomShape::CustomShape() : Shape()
 {
-	CustomShape(0);
+  CustomShape(0);
 };
 
 CustomShape::CustomShape ( int id ) : Shape()
 {
+  Param * param;
 
-	Param * param;
+  this->id = id;
+  this->per_frame_count = 0;
 
-	this->id = id;
-	this->per_frame_count = 0;
-
-	/* Start: Load custom shape parameters */
-	param = Param::new_param_float ( "r", P_FLAG_NONE, &this->r, NULL, 1.0, 0.0, 0.5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "g", P_FLAG_NONE, &this->g, NULL, 1.0, 0.0, .5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "b", P_FLAG_NONE, &this->b, NULL, 1.0, 0.0, .5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "a", P_FLAG_NONE, &this->a, NULL, 1.0, 0.0, .5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "border_r", P_FLAG_NONE, &this->border_r, NULL, 1.0, 0.0, .5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "border_g", P_FLAG_NONE, &this->border_g, NULL, 1.0, 0.0, .5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "border_b", P_FLAG_NONE, &this->border_b, NULL, 1.0, 0.0, .5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "border_a", P_FLAG_NONE, &this->border_a, NULL, 1.0, 0.0, .5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "r2", P_FLAG_NONE, &this->r2, NULL, 1.0, 0.0, .5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "g2", P_FLAG_NONE, &this->g2, NULL, 1.0, 0.0, .5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "b2", P_FLAG_NONE, &this->b2, NULL, 1.0, 0.0, .5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "a2", P_FLAG_NONE, &this->a2, NULL, 1.0, 0.0, .5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "x", P_FLAG_NONE, &this->x, NULL, 1.0, 0.0, .5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "y", P_FLAG_NONE, &this->y, NULL, 1.0, 0.0, .5 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_bool ( "thickoutline", P_FLAG_NONE, &this->thickOutline, 1, 0, 0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_bool ( "enabled", P_FLAG_NONE, &this->enabled, 1, 0, 0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_int ( "sides", P_FLAG_NONE, &this->sides, 100, 3, 3 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_bool ( "additive", P_FLAG_NONE, &this->additive, 1, 0, 0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_bool ( "textured", P_FLAG_NONE, &this->textured, 1, 0, 0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "rad", P_FLAG_NONE, &this->radius, NULL, MAX_DOUBLE_SIZE, 0, 0.0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "ang", P_FLAG_NONE, &this->ang, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "tex_zoom", P_FLAG_NONE, &this->tex_zoom, NULL, MAX_DOUBLE_SIZE, .00000000001, 0.0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "tex_ang", P_FLAG_NONE, &this->tex_ang, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-
-	param = Param::new_param_float ( "t1", P_FLAG_TVAR, &this->t1, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "t2", P_FLAG_TVAR, &this->t2, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "t3", P_FLAG_TVAR, &this->t3, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "t4", P_FLAG_TVAR, &this->t4, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "t5", P_FLAG_TVAR, &this->t5, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "t6", P_FLAG_TVAR, &this->t6, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "t7", P_FLAG_TVAR, &this->t7, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-	param = Param::new_param_float ( "t8", P_FLAG_TVAR, &this->t8, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
-	if ( !ParamUtils::insert( param, &this->param_tree ) )
-	{
-		abort();
-	}
-
-   for (unsigned int i = 1; i <= NUM_Q_VARIABLES;i++) {
-	std::ostringstream os;
-	os << "q" << i;
-	param = Param::new_param_float ( os.str().c_str(), P_FLAG_QVAR, &this->q[i], NULL, MAX_DOUBLE_SIZE,
-		 -MAX_DOUBLE_SIZE, 0.0 );
-	if ( ParamUtils::insert ( param, &this->param_tree ) < 0 )
-	{
-		abort();
-	}
+  /* Start: Load custom shape parameters */
+  param = Param::new_param_float ( "r", P_FLAG_NONE, &this->r, NULL, 1.0, 0.0, 0.5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "g", P_FLAG_NONE, &this->g, NULL, 1.0, 0.0, .5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "b", P_FLAG_NONE, &this->b, NULL, 1.0, 0.0, .5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "a", P_FLAG_NONE, &this->a, NULL, 1.0, 0.0, .5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "border_r", P_FLAG_NONE, &this->border_r, NULL, 1.0, 0.0, .5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "border_g", P_FLAG_NONE, &this->border_g, NULL, 1.0, 0.0, .5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "border_b", P_FLAG_NONE, &this->border_b, NULL, 1.0, 0.0, .5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "border_a", P_FLAG_NONE, &this->border_a, NULL, 1.0, 0.0, .5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "r2", P_FLAG_NONE, &this->r2, NULL, 1.0, 0.0, .5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "g2", P_FLAG_NONE, &this->g2, NULL, 1.0, 0.0, .5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "b2", P_FLAG_NONE, &this->b2, NULL, 1.0, 0.0, .5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "a2", P_FLAG_NONE, &this->a2, NULL, 1.0, 0.0, .5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "x", P_FLAG_NONE, &this->x, NULL, 1.0, 0.0, .5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "y", P_FLAG_NONE, &this->y, NULL, 1.0, 0.0, .5 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_bool ( "thickoutline", P_FLAG_NONE, &this->thickOutline, 1, 0, 0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_bool ( "enabled", P_FLAG_NONE, &this->enabled, 1, 0, 0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_int ( "sides", P_FLAG_NONE, &this->sides, 100, 3, 3 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_bool ( "additive", P_FLAG_NONE, &this->additive, 1, 0, 0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_bool ( "textured", P_FLAG_NONE, &this->textured, 1, 0, 0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "rad", P_FLAG_NONE, &this->radius, NULL, MAX_DOUBLE_SIZE, 0, 0.0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "ang", P_FLAG_NONE, &this->ang, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "tex_zoom", P_FLAG_NONE, &this->tex_zoom, NULL, MAX_DOUBLE_SIZE, .00000000001, 0.0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "tex_ang", P_FLAG_NONE, &this->tex_ang, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
   }
 
-	param = Param::new_param_string ( "imageurl", P_FLAG_NONE, &this->imageUrl);
-	if ( !ParamUtils::insert( param, &this->text_properties_tree ) )
-	{
-		abort();
-	}
+  param = Param::new_param_float ( "t1", P_FLAG_TVAR, &this->t1, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "t2", P_FLAG_TVAR, &this->t2, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "t3", P_FLAG_TVAR, &this->t3, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "t4", P_FLAG_TVAR, &this->t4, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "t5", P_FLAG_TVAR, &this->t5, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "t6", P_FLAG_TVAR, &this->t6, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "t7", P_FLAG_TVAR, &this->t7, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
+  param = Param::new_param_float ( "t8", P_FLAG_TVAR, &this->t8, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
+  if ( !ParamUtils::insert( param, &this->param_tree ) )
+  {
+    abort();
+  }
 
+  for (unsigned int i = 1;  i <= NUM_Q_VARIABLES;  i++) {
+    std::ostringstream os;
+
+    os << "q" << i;
+    param = Param::new_param_float ( os.str().c_str(), P_FLAG_QVAR, &this->q[i], NULL,
+                                     MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
+    if ( ParamUtils::insert ( param, &this->param_tree ) < 0 )
+    {
+      abort();
+    }
+  }
+
+  param = Param::new_param_string ( "imageurl", P_FLAG_NONE, &this->imageUrl);
+  if ( !ParamUtils::insert( param, &this->text_properties_tree ) )
+  {
+    abort();
+  }
 }
 
 /* Frees a custom shape form object */
 CustomShape::~CustomShape()
 {
-
-	traverseVector<TraverseFunctors::Delete<PerFrameEqn> > ( per_frame_eqn_tree );
-	traverse<TraverseFunctors::Delete<InitCond> > ( init_cond_tree );
-	traverse<TraverseFunctors::Delete<Param> > ( param_tree );
-	traverse<TraverseFunctors::Delete<InitCond> > ( per_frame_init_eqn_tree );
-	traverse<TraverseFunctors::Delete<Param> > ( text_properties_tree );
-
+  traverseVector<TraverseFunctors::Delete<PerFrameEqn> > ( per_frame_eqn_tree );
+  traverse<TraverseFunctors::Delete<InitCond> > ( init_cond_tree );
+  traverse<TraverseFunctors::Delete<Param> > ( param_tree );
+  traverse<TraverseFunctors::Delete<InitCond> > ( per_frame_init_eqn_tree );
+  traverse<TraverseFunctors::Delete<Param> > ( text_properties_tree );
 }
 
-void CustomShape::loadUnspecInitConds()
+void
+CustomShape::loadUnspecInitConds()
 {
-
-	InitCondUtils::LoadUnspecInitCond fun ( this->init_cond_tree, this->per_frame_init_eqn_tree );
-	traverse ( param_tree, fun );
+  InitCondUtils::LoadUnspecInitCond fun ( this->init_cond_tree, this->per_frame_init_eqn_tree );
+  traverse ( param_tree, fun );
 }
 
-void CustomShape::evalInitConds()
+void
+CustomShape::evalInitConds()
 {
-	// NOTE: This is verified to be same behavior as trunk
-	for ( std::map<std::string, InitCond*>::iterator pos = per_frame_init_eqn_tree.begin(); 
-		     pos != per_frame_init_eqn_tree.end();++pos )
-		pos->second->evaluate();
+  // NOTE: This is verified to be same behavior as trunk
+  for (std::map<std::string, InitCond*>::iterator pos = per_frame_init_eqn_tree.begin();
+       pos != per_frame_init_eqn_tree.end();
+       ++pos)
+    pos->second->evaluate();
 }
diff --git a/src/libprojectM/MilkdropPresetFactory/CustomShape.hpp b/src/libprojectM/MilkdropPresetFactory/CustomShape.hpp
index eb9a8e8..6fbbe34 100644
--- a/src/libprojectM/MilkdropPresetFactory/CustomShape.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/CustomShape.hpp
@@ -25,7 +25,6 @@
  *
  * $Log$
  */
-
 #ifndef _CUSTOM_SHAPE_H
 #define _CUSTOM_SHAPE_H
 
@@ -37,54 +36,53 @@
 #include "Renderer/Renderable.hpp"
 #include <vector>
 
+
 class Preset;
 
 
 class CustomShape : public Shape {
 public:
-    /* Numerical id */
-    int id;
-    int per_frame_count;
+  /* Numerical id */
+  int id;
+  int per_frame_count;
 
-    /* Parameter tree associated with this custom shape */
-    std::map<std::string,Param*> param_tree;
+  /* Parameter tree associated with this custom shape */
+  std::map<std::string,Param*> param_tree;
 
-    /* Engine variables */
+  /* Engine variables */
 
-    bool enabled;
+  bool enabled;
 
-    /* stupid t variables */
-    float t1;
-    float t2;
-    float t3;
-    float t4;
-    float t5;
-    float t6;
-    float t7;
-    float t8;
+  /* stupid t variables */
+  float t1;
+  float t2;
+  float t3;
+  float t4;
+  float t5;
+  float t6;
+  float t7;
+  float t8;
 
-    /* stupider q variables */
-    float q[NUM_Q_VARIABLES];
+  /* stupider q variables */
+  float q[NUM_Q_VARIABLES];
 
-    // Data structure to hold per frame  / per frame init equations
-    std::map<std::string,InitCond*>  init_cond_tree;
-    std::vector<PerFrameEqn*>  per_frame_eqn_tree;
-    std::map<std::string,InitCond*>  per_frame_init_eqn_tree;
+  // Data structure to hold per frame  / per frame init equations
+  std::map<std::string,InitCond*> init_cond_tree;
+  std::vector<PerFrameEqn*>       per_frame_eqn_tree;
+  std::map<std::string,InitCond*> per_frame_init_eqn_tree;
 
-    std::map<std::string, Param*> text_properties_tree;
+  std::map<std::string, Param*>   text_properties_tree;
 
 
-    /// Allocate a new custom shape, including param associations, per point equations, and initial values.
-    /// \param id an integer id to associate with this custom wave. Future line parsing uses this as a reference key.
-    CustomShape( int id );
-    CustomShape();
-    ~CustomShape();
+  /// Allocate a new custom shape, including param associations, per point equations, and initial values.
+  /// \param id an integer id to associate with this custom wave. Future line parsing uses this as a reference key.
+  CustomShape( int id );
+  CustomShape();
+  ~CustomShape();
 
-    void loadUnspecInitConds();
-    void evalInitConds();
-
-  };
+  void loadUnspecInitConds();
+  void evalInitConds();
+};
 
 
 #endif /** !_CUSTOM_SHAPE_H */
-
diff --git a/src/libprojectM/MilkdropPresetFactory/CustomWave.cpp b/src/libprojectM/MilkdropPresetFactory/CustomWave.cpp
index 935cea7..305d663 100644
--- a/src/libprojectM/MilkdropPresetFactory/CustomWave.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/CustomWave.cpp
@@ -40,10 +40,12 @@
 #include "ParamUtils.hpp"
 #include "InitCondUtils.hpp"
 #include "wipemalloc.h"
+
 #define MAX_SAMPLE_SIZE 4096
 
 
-CustomWave::CustomWave(int _id) : Waveform(512),
+CustomWave::CustomWave(int _id)
+  : Waveform(512),
     id(_id),
     per_frame_count(0),
     r(0),
@@ -51,7 +53,6 @@
     b(0),
     a(0)
 {
-
   Param * param;
 
   /// @bug deprecate the use of wipemalloc
@@ -147,10 +148,8 @@
   if (ParamUtils::insert(param, &this->param_tree) < 0)
   {
     ;
-
     /// @bug make exception
     abort();
-
   }
 
   if ((param = Param::new_param_bool("enabled", P_FLAG_NONE, &this->enabled, 1, 0, 0)) == NULL)
@@ -158,17 +157,13 @@
     ;
     /// @bug make exception
     abort();
-
-
   }
 
   if (ParamUtils::insert(param, &this->param_tree) < 0)
   {
     ;
-
     /// @bug make exception
     abort();
-
   }
 
   if ((param = Param::new_param_int("sep", P_FLAG_NONE, &this->sep, 100, -100, 0)) == NULL)
@@ -176,8 +171,6 @@
     ;
     /// @bug make exception
     abort();
-
-
   }
 
   if (ParamUtils::insert(param, &this->param_tree) < 0)
@@ -185,23 +178,18 @@
     ;
     /// @bug make exception
     abort();
-
-
   }
 
   if ((param = Param::new_param_bool("bspectrum", P_FLAG_NONE, &this->spectrum, 1, 0, 0)) == NULL)
   {
     /// @bug make exception
     abort();
-
-
   }
 
   if (ParamUtils::insert(param, &this->param_tree) < 0)
   {
     /// @bug make exception
     abort();
-
   }
 
   if ((param = Param::new_param_bool("bdrawthick", P_FLAG_NONE, &this->thick, 1, 0, 0)) == NULL)
@@ -214,12 +202,10 @@
   {
     /// @bug make exception
     abort();
-
   }
 
   if ((param = Param::new_param_bool("busedots", P_FLAG_NONE, &this->dots, 1, 0, 0)) == NULL)
   {
-
     /// @bug make exception
     abort();
   }
@@ -255,7 +241,7 @@
   }
 
   if ((param = Param::new_param_float("sample", P_FLAG_READONLY | P_FLAG_NONE | P_FLAG_ALWAYS_MATRIX | P_FLAG_PER_POINT,
-                                      &this->sample, this->sample_mesh, 1.0, 0.0, 0.0)) == NULL)
+                      &this->sample, this->sample_mesh, 1.0, 0.0, 0.0)) == NULL)
   {
     ;
     abort();
@@ -341,12 +327,11 @@
 
   if (ParamUtils::insert(param, &this->param_tree) < 0)
   {
-
     abort();
   }
+
   if ((param = Param::new_param_float("t4",  P_FLAG_PER_POINT |P_FLAG_TVAR, &this->t4, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0)) == NULL)
   {
-
     abort();
   }
 
@@ -354,6 +339,7 @@
   {
     abort();
   }
+
   if ((param = Param::new_param_float("t5", P_FLAG_TVAR, &this->t5, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0)) == NULL)
   {
     abort();
@@ -363,7 +349,7 @@
   {
     abort();
   }
-  
+
   if ((param = Param::new_param_float("t6", P_FLAG_TVAR | P_FLAG_PER_POINT, &this->t6, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0)) == NULL)
   {
     abort();
@@ -371,12 +357,11 @@
 
   if (ParamUtils::insert(param, &this->param_tree) < 0)
   {
-
     abort();
   }
+
   if ((param = Param::new_param_float("t7", P_FLAG_TVAR | P_FLAG_PER_POINT, &this->t7, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0)) == NULL)
   {
-
     abort();
   }
 
@@ -398,27 +383,25 @@
     abort();
   }
 
-  for (unsigned int i = 1; i <= NUM_Q_VARIABLES;i++) {
-	std::ostringstream os;
-	os << "q" << i;
-	param = Param::new_param_float ( os.str().c_str(), P_FLAG_QVAR, &this->q[i], NULL, MAX_DOUBLE_SIZE,
-		 -MAX_DOUBLE_SIZE, 0.0 );
-	if ( ParamUtils::insert ( param, &this->param_tree ) < 0 )
-	{
-		abort();
-	}
+  for (unsigned int i = 1;  i <= NUM_Q_VARIABLES;  i++) {
+    std::ostringstream os;
+
+    os << "q" << i;
+    param = Param::new_param_float ( os.str().c_str(), P_FLAG_QVAR, &this->q[i], NULL,
+                                     MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0 );
+    if ( ParamUtils::insert ( param, &this->param_tree ) < 0 )
+    {
+      abort();
+    }
   }
-	
-     /* End of parameter loading. Note that the read only parameters associated
+
+  /* End of parameter loading. Note that the read only parameters associated
      with custom waves (ie, sample) are variables stored in PresetFrameIO.hpp,
      and not specific to the custom wave datastructure. */
-
 }
 
 CustomWave::~CustomWave()
 {
-
-
   for (std::vector<PerPointEqn*>::iterator pos = per_point_eqn_tree.begin(); pos != per_point_eqn_tree.end(); ++pos)
     delete(*pos);
 
@@ -434,23 +417,23 @@
   for (std::map<std::string, Param*>::iterator pos = param_tree.begin(); pos != param_tree.end(); ++pos)
     delete(pos->second);
 
-  free(r_mesh);
-  free(g_mesh);
-  free(b_mesh);
-  free(a_mesh);
-  free(x_mesh);
-  free(y_mesh);
-  free(value1);
-  free(value2);
-  free(sample_mesh);
-
+  free (r_mesh);
+  free (g_mesh);
+  free (b_mesh);
+  free (a_mesh);
+  free (x_mesh);
+  free (y_mesh);
+  free (value1);
+  free (value2);
+  free (sample_mesh);
 }
 
 
 
 
 // Comments: index is not passed, so we assume monotonic increment by 1 is ok here
-int CustomWave::add_per_point_eqn(char * name, GenExpr * gen_expr)
+int
+CustomWave::add_per_point_eqn(char * name, GenExpr * gen_expr)
 {
 
   PerPointEqn * per_point_eqn;
@@ -469,9 +452,9 @@
 
   if ((param = ParamUtils::find<ParamUtils::AUTO_CREATE>(name,&param_tree)) == NULL)
   {
-    if (CUSTOM_WAVE_DEBUG) printf("add_per_point_eqn: failed to allocate a new parameter!\n");
+    if (CUSTOM_WAVE_DEBUG)
+      printf("add_per_point_eqn: failed to allocate a new parameter!\n");
     return PROJECTM_FAILURE;
-
   }
 
   /* Get largest index in the tree */
@@ -480,6 +463,7 @@
   /* Create the per point equation given the index, parameter, and general expression */
   if ((per_point_eqn = new PerPointEqn(index, param, gen_expr, samples)) == NULL)
     return PROJECTM_FAILURE;
+
   if (CUSTOM_WAVE_DEBUG)
     printf("add_per_point_eqn: created new equation (index = %d) (name = \"%s\")\n", per_point_eqn->index, per_point_eqn->param->name.c_str());
 
@@ -492,48 +476,51 @@
 }
 
 
-void CustomWave::evalInitConds()
+void
+CustomWave::evalInitConds()
 {
-
-  for (std::map<std::string, InitCond*>::iterator pos = per_frame_init_eqn_tree.begin(); pos != per_frame_init_eqn_tree.end(); ++pos)
+  for (std::map<std::string, InitCond*>::iterator pos = per_frame_init_eqn_tree.begin();
+       pos != per_frame_init_eqn_tree.end();
+       ++pos)
   {
     assert(pos->second);
     pos->second->evaluate();
   }
-
 }
 
-ColoredPoint CustomWave::PerPoint(ColoredPoint p, const WaveformContext context)
+ColoredPoint
+CustomWave::PerPoint (ColoredPoint p, const WaveformContext context)
 {
-	    r_mesh[context.sample_int] = r;
-	    g_mesh[context.sample_int] = g;
-	    b_mesh[context.sample_int] = b;
-	    a_mesh[context.sample_int] = a;
-	    x_mesh[context.sample_int] = x;
-	    y_mesh[context.sample_int] = y;
-	    sample = context.sample;
-	    sample_mesh[context.sample_int] = context.sample;
-	    v1 = context.left;
-	    v2 = context.right;
+  r_mesh[context.sample_int] = r;
+  g_mesh[context.sample_int] = g;
+  b_mesh[context.sample_int] = b;
+  a_mesh[context.sample_int] = a;
+  x_mesh[context.sample_int] = x;
+  y_mesh[context.sample_int] = y;
+  sample = context.sample;
+  sample_mesh[context.sample_int] = context.sample;
+  v1 = context.left;
+  v2 = context.right;
 
-	for (std::vector<PerPointEqn*>::iterator pos = per_point_eqn_tree.begin(); pos != per_point_eqn_tree.end();++pos)
-	    (*pos)->evaluate(context.sample_int);
+  for (std::vector<PerPointEqn*>::iterator pos = per_point_eqn_tree.begin();
+       pos != per_point_eqn_tree.end();
+       ++pos)
+    (*pos)->evaluate(context.sample_int);
 
-	    p.a = a_mesh[context.sample_int];
-	    p.r = r_mesh[context.sample_int];
-	    p.g = g_mesh[context.sample_int];
-	    p.b = b_mesh[context.sample_int];
-	    p.x = x_mesh[context.sample_int];
-	    p.y = y_mesh[context.sample_int];
+  p.a = a_mesh[context.sample_int];
+  p.r = r_mesh[context.sample_int];
+  p.g = g_mesh[context.sample_int];
+  p.b = b_mesh[context.sample_int];
+  p.x = x_mesh[context.sample_int];
+  p.y = y_mesh[context.sample_int];
 
-	    return p;
+  return p;
 }
 
 
-void CustomWave::loadUnspecInitConds()
+void
+CustomWave::loadUnspecInitConds()
 {
-
   InitCondUtils::LoadUnspecInitCond fun(this->init_cond_tree, this->per_frame_init_eqn_tree);
   traverse(param_tree, fun);
 }
-
diff --git a/src/libprojectM/MilkdropPresetFactory/CustomWave.hpp b/src/libprojectM/MilkdropPresetFactory/CustomWave.hpp
index a951fed..a29a4e3 100644
--- a/src/libprojectM/MilkdropPresetFactory/CustomWave.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/CustomWave.hpp
@@ -29,6 +29,7 @@
 #ifndef _CUSTOM_WAVE_H
 #define _CUSTOM_WAVE_H
 
+
 #define CUSTOM_WAVE_DEBUG 0
 
 class CustomWave;
@@ -45,84 +46,84 @@
 
 #include <map>
 
+
 class CustomWave : public Waveform
 {
-public:
+  public:
 
-     /** Empty constructor leaves wave in undefined state **/
-     //CustomWave() {}
+  /** Empty constructor leaves wave in undefined state **/
+  //CustomWave() {}
 
-     /** Initializes a custom wave id given the integer id */
-     CustomWave(int id);
+  /** Initializes a custom wave id given the integer id */
+  CustomWave(int id);
 
-    /** Destructor is necessary so we can free the per point matrices **/
-    ~CustomWave();
+  /** Destructor is necessary so we can free the per point matrices **/
+  ~CustomWave();
 
-    ColoredPoint PerPoint(ColoredPoint p, const WaveformContext context);
+  ColoredPoint PerPoint(ColoredPoint p, const WaveformContext context);
 
-    /* Numerical id */
-    int id;
-    int per_frame_count;
+  /* Numerical id */
+  int id;
+  int per_frame_count;
 
-    /* Parameter tree associated with this custom wave */
-    std::map<std::string,Param*> param_tree;
+  /* Parameter tree associated with this custom wave */
+  std::map<std::string,Param*> param_tree;
 
-    /* Engine variables */
-    float x; /* x position for per point equations */
-    float y; /* y position for per point equations */
-    float r; /* red color value */
-    float g; /* green color value */
-    float b; /* blue color value */
-    float a; /* alpha color value */
-    float * x_mesh;
-    float * y_mesh;
-    float * r_mesh;
-    float * b_mesh;
-    float * g_mesh;
-    float * a_mesh;
-    float * value1;
-    float * value2;
-    float * sample_mesh;
+  /* Engine variables */
+  float x; /* x position for per point equations */
+  float y; /* y position for per point equations */
+  float r; /* red color value */
+  float g; /* green color value */
+  float b; /* blue color value */
+  float a; /* alpha color value */
+  float * x_mesh;
+  float * y_mesh;
+  float * r_mesh;
+  float * b_mesh;
+  float * g_mesh;
+  float * a_mesh;
+  float * value1;
+  float * value2;
+  float * sample_mesh;
 
-    bool enabled; /* if true then wave is visible, hidden otherwise */
+  bool  enabled; /* if true then wave is visible, hidden otherwise */
 
-    float sample;
+  float sample;
 
-    /* stupid t variables */
-    float t1;
-    float t2;
-    float t3;
-    float t4;
-    float t5;
-    float t6;
-    float t7;
-    float t8;
+  /* stupid t variables */
+  float t1;
+  float t2;
+  float t3;
+  float t4;
+  float t5;
+  float t6;
+  float t7;
+  float t8;
 
 
-    /* stupider q variables */
-    float q[NUM_Q_VARIABLES];
+  /* stupider q variables */
+  float q[NUM_Q_VARIABLES];
 
-    float v1,v2;
+  float v1,v2;
 
-    /* Data structures to hold per frame and per point equations */
-    std::map<std::string,InitCond*>  init_cond_tree;
-    std::vector<PerFrameEqn*>  per_frame_eqn_tree;
-    std::vector<PerPointEqn*>  per_point_eqn_tree;
-    std::map<std::string,InitCond*>  per_frame_init_eqn_tree;
+  /* Data structures to hold per frame and per point equations */
+  std::map<std::string,InitCond*> init_cond_tree;
+  std::vector<PerFrameEqn*>       per_frame_eqn_tree;
+  std::vector<PerPointEqn*>       per_point_eqn_tree;
+  std::map<std::string,InitCond*> per_frame_init_eqn_tree;
 
-    /* Denotes the index of the last character for each string buffer */
-    int per_point_eqn_string_index;
-    int per_frame_eqn_string_index;
-    int per_frame_init_eqn_string_index;
+  /* Denotes the index of the last character for each string buffer */
+  int per_point_eqn_string_index;
+  int per_frame_eqn_string_index;
+  int per_frame_init_eqn_string_index;
 
-    int add_per_point_eqn(char * name, GenExpr * gen_expr);
-    void evalCustomWaveInitConditions(Preset *preset);
-    
+  int add_per_point_eqn(char * name, GenExpr * gen_expr);
+  void evalCustomWaveInitConditions(Preset *preset);
 
-    void loadUnspecInitConds();
 
-    void evalInitConds();
+  void loadUnspecInitConds();
 
+  void evalInitConds();
 };
 
 #endif /** !_CUSTOM_WAVE_H */
diff --git a/src/libprojectM/MilkdropPresetFactory/Eval.cpp b/src/libprojectM/MilkdropPresetFactory/Eval.cpp
index 1810f74..3183754 100644
--- a/src/libprojectM/MilkdropPresetFactory/Eval.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/Eval.cpp
@@ -34,58 +34,61 @@
 
 #include "BuiltinFuncs.hpp"
 
-InfixOp *Eval::infix_add = NULL;
-InfixOp *Eval::infix_minus = NULL;
-InfixOp *Eval::infix_div = NULL;
-InfixOp *Eval::infix_mult = NULL;
-InfixOp *Eval::infix_or = NULL;
-InfixOp *Eval::infix_and = NULL;
-InfixOp *Eval::infix_mod = NULL;
+
+InfixOp *Eval::infix_add      = NULL;
+InfixOp *Eval::infix_minus    = NULL;
+InfixOp *Eval::infix_div      = NULL;
+InfixOp *Eval::infix_mult     = NULL;
+InfixOp *Eval::infix_or       = NULL;
+InfixOp *Eval::infix_and      = NULL;
+InfixOp *Eval::infix_mod      = NULL;
 InfixOp *Eval::infix_negative = NULL;
 InfixOp *Eval::infix_positive = NULL;
 
+
 /* Initializes all infix operators */
-int Eval::init_infix_ops() {
+int
+Eval::init_infix_ops()
+{
+  Eval::infix_add       = new InfixOp (INFIX_ADD, 4);
+  Eval::infix_minus     = new InfixOp (INFIX_MINUS, 3);
+  Eval::infix_div       = new InfixOp (INFIX_DIV, 2);
+  Eval::infix_or        = new InfixOp (INFIX_OR, 5);
+  Eval::infix_and       = new InfixOp (INFIX_AND,4);
+  Eval::infix_mod       = new InfixOp (INFIX_MOD, 1);
+  Eval::infix_mult      = new InfixOp (INFIX_MULT, 2);
 
-	Eval::infix_add = new InfixOp(INFIX_ADD, 4);
-	Eval::infix_minus = new InfixOp(INFIX_MINUS, 3);
-	Eval::infix_div = new InfixOp(INFIX_DIV, 2);
-	Eval::infix_or = new InfixOp(INFIX_OR, 5);
-	Eval::infix_and = new InfixOp(INFIX_AND,4);
-	Eval::infix_mod = new InfixOp(INFIX_MOD, 1);
-	Eval::infix_mult = new InfixOp(INFIX_MULT, 2);
-	
-	/* Prefix operators */
-	Eval::infix_positive = new InfixOp(INFIX_ADD, 0);
-	Eval::infix_negative = new InfixOp(INFIX_MINUS, 0);
+  /* Prefix operators */
+  Eval::infix_positive  = new InfixOp (INFIX_ADD, 0);
+  Eval::infix_negative  = new InfixOp (INFIX_MINUS, 0);
 
-	return PROJECTM_SUCCESS;
+  return PROJECTM_SUCCESS;
 }
 
 /* Destroys the infix operator list. This should
    be done on program exit */
-int Eval::destroy_infix_ops()
+int
+Eval::destroy_infix_ops()
 {
+  delete (Eval::infix_add);
+  delete (Eval::infix_minus);
+  delete (Eval::infix_div);
+  delete (Eval::infix_or);
+  delete (Eval::infix_and);
+  delete (Eval::infix_mod);
+  delete (Eval::infix_mult);
+  delete (Eval::infix_positive);
+  delete (Eval::infix_negative);
 
-  delete(Eval::infix_add);
-  delete(Eval::infix_minus);
-  delete(Eval::infix_div);
-  delete(Eval::infix_or);
-  delete(Eval::infix_and);
-  delete(Eval::infix_mod);
-  delete(Eval::infix_mult);
-  delete(Eval::infix_positive);
-  delete(Eval::infix_negative);
-
-  Eval::infix_add = NULL;
-  Eval::infix_minus = NULL;
-  Eval::infix_div = NULL;
-  Eval::infix_or = NULL;
-  Eval::infix_and = NULL;
-  Eval::infix_mod = NULL;
-  Eval::infix_mult = NULL;
-  Eval::infix_positive = NULL;
-  Eval::infix_negative = NULL;
+  Eval::infix_add       = NULL;
+  Eval::infix_minus     = NULL;
+  Eval::infix_div       = NULL;
+  Eval::infix_or        = NULL;
+  Eval::infix_and       = NULL;
+  Eval::infix_mod       = NULL;
+  Eval::infix_mult      = NULL;
+  Eval::infix_positive  = NULL;
+  Eval::infix_negative  = NULL;
 
   return PROJECTM_SUCCESS;
 }
diff --git a/src/libprojectM/MilkdropPresetFactory/Eval.hpp b/src/libprojectM/MilkdropPresetFactory/Eval.hpp
index 51bd22f..6be653c 100644
--- a/src/libprojectM/MilkdropPresetFactory/Eval.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/Eval.hpp
@@ -36,59 +36,62 @@
 #include "Func.hpp"
 #include "Param.hpp"
 
-#define EVAL_DEBUG 0
+
+#define EVAL_DEBUG      0
 //#define EVAL_DEBUG_DOUBLE 2
 
-#define VAL_T 1
-#define PREFUN_T 3
-#define TREE_T 4
-#define NONE_T 0
+#define VAL_T           1
+#define PREFUN_T        3
+#define TREE_T          4
+#define NONE_T          0
 
 #define CONSTANT_TERM_T 0
-#define PARAM_TERM_T 1
+#define PARAM_TERM_T    1
 
-#define INFIX_ADD 0
-#define INFIX_MINUS 1
-#define INFIX_MOD 2
-#define INFIX_DIV 3
-#define INFIX_MULT 4
-#define INFIX_OR 5
-#define INFIX_AND 6
+#define INFIX_ADD       0
+#define INFIX_MINUS     1
+#define INFIX_MOD       2
+#define INFIX_DIV       3
+#define INFIX_MULT      4
+#define INFIX_OR        5
+#define INFIX_AND       6
+
 
 class DLLEXPORT InfixOp;
 
+
 class Eval {
 public:
-    static InfixOp *infix_add,
-                   *infix_minus,
-                   *infix_div,
-                   *infix_mult,
-                   *infix_or,
-                   *infix_and,
-                   *infix_mod,
-                   *infix_negative,
-                   *infix_positive;
+  static InfixOp *infix_add,
+                 *infix_minus,
+                 *infix_div,
+                 *infix_mult,
+                 *infix_or,
+                 *infix_and,
+                 *infix_mod,
+                 *infix_negative,
+                 *infix_positive;
 
-    float eval_gen_expr(GenExpr * gen_expr);
-    inline GenExpr * opt_gen_expr(GenExpr * gen_expr, int ** param_list);
+  float eval_gen_expr(GenExpr * gen_expr);
+  inline GenExpr * opt_gen_expr(GenExpr * gen_expr, int ** param_list);
 
-    GenExpr * const_to_expr(float val);
-    GenExpr * param_to_expr(Param * param);
-    GenExpr * prefun_to_expr(float (*func_ptr)(), GenExpr ** expr_list, int num_args);
+  GenExpr * const_to_expr(float val);
+  GenExpr * param_to_expr(Param * param);
+  GenExpr * prefun_to_expr(float (*func_ptr)(), GenExpr ** expr_list, int num_args);
 
-    static TreeExpr * new_tree_expr(InfixOp * infix_op, GenExpr * gen_expr, TreeExpr * left, TreeExpr * right);
-    static GenExpr * new_gen_expr(int type, void * item);
-    static ValExpr * new_val_expr(int type, Term *term);
+  static TreeExpr * new_tree_expr(InfixOp * infix_op, GenExpr * gen_expr, TreeExpr * left, TreeExpr * right);
+  static GenExpr * new_gen_expr(int type, void * item);
+  static ValExpr * new_val_expr(int type, Term *term);
 
-    static InfixOp * new_infix_op(int type, int precedence);
-    static int init_infix_ops();
-    static int destroy_infix_ops();
-    void reset_engine_vars();
-    
-    GenExpr * clone_gen_expr(GenExpr * gen_expr);
-    TreeExpr * clone_tree_expr(TreeExpr * tree_expr);
-    ValExpr * clone_val_expr(ValExpr * val_expr);
-    PrefunExpr * clone_prefun_expr(PrefunExpr * prefun_expr);
-  };
+  static InfixOp * new_infix_op(int type, int precedence);
+  static int init_infix_ops();
+  static int destroy_infix_ops();
+  void reset_engine_vars();
+
+  GenExpr * clone_gen_expr(GenExpr * gen_expr);
+  TreeExpr * clone_tree_expr(TreeExpr * tree_expr);
+  ValExpr * clone_val_expr(ValExpr * val_expr);
+  PrefunExpr * clone_prefun_expr(PrefunExpr * prefun_expr);
+};
 
 #endif /** !_EVAL_H */
diff --git a/src/libprojectM/MilkdropPresetFactory/Expr.cpp b/src/libprojectM/MilkdropPresetFactory/Expr.cpp
index 2f3efdf..92e5985 100644
--- a/src/libprojectM/MilkdropPresetFactory/Expr.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/Expr.cpp
@@ -27,310 +27,311 @@
 #include <iostream>
 #include "Eval.hpp"
 
-float GenExpr::eval_gen_expr ( int mesh_i, int mesh_j )
+float
+GenExpr::eval_gen_expr ( int mesh_i, int mesh_j )
 {
-	float l;
+  float l;
 
-	if (item == 0)
-		return EVAL_ERROR;
+  if (item == 0)
+    return EVAL_ERROR;
 
-	switch ( this->type )
-	{
-		case VAL_T:
-			return ( ( ValExpr* ) item )->eval_val_expr ( mesh_i, mesh_j );
-		case PREFUN_T:
-			l = ( ( PrefunExpr * ) item )->eval_prefun_expr ( mesh_i, mesh_j );
-			//if (EVAL_DEBUG) DWRITE( "eval_gen_expr: prefix function return value: %f\n", l);
-			return l;
-		case TREE_T:
-			return ( ( TreeExpr* ) ( item ) )->eval_tree_expr ( mesh_i, mesh_j );
-		default:
-			return EVAL_ERROR;
-	}
-
+  switch ( this->type )
+  {
+  case VAL_T:
+    return ( ( ValExpr* ) item )->eval_val_expr ( mesh_i, mesh_j );
+  case PREFUN_T:
+    l = ( ( PrefunExpr * ) item )->eval_prefun_expr ( mesh_i, mesh_j );
+    //if (EVAL_DEBUG) DWRITE( "eval_gen_expr: prefix function return value: %f\n", l);
+    return l;
+  case TREE_T:
+    return ( ( TreeExpr* ) ( item ) )->eval_tree_expr ( mesh_i, mesh_j );
+  default:
+    return EVAL_ERROR;
+  }
 }
 
 /* Evaluates functions in prefix form */
-float PrefunExpr::eval_prefun_expr ( int mesh_i, int mesh_j )
+float
+PrefunExpr::eval_prefun_expr ( int mesh_i, int mesh_j )
 {
+  assert ( func_ptr );
 
+  float * arg_list = new float[this->num_args];
 
-	assert ( func_ptr );
+  assert(arg_list);
 
-	float * arg_list = new float[this->num_args];
+  //printf("numargs %d", num_args);
 
-	assert(arg_list);
+  /* Evaluate each argument before calling the function itself */
+  for ( int i = 0; i < num_args; i++ )
+  {
+    arg_list[i] = expr_list[i]->eval_gen_expr ( mesh_i, mesh_j );
+    //printf("numargs %x", arg_list[i]);
+  }
+  /* Now we call the function, passing a list of
+     floats as its argument */
 
-	//printf("numargs %d", num_args);
+  const float value = ( func_ptr ) ( arg_list );
 
-	/* Evaluate each argument before calling the function itself */
-	for ( int i = 0; i < num_args; i++ )
-	{
-		arg_list[i] = expr_list[i]->eval_gen_expr ( mesh_i, mesh_j );
-		//printf("numargs %x", arg_list[i]);
-
-
-	}
-	/* Now we call the function, passing a list of
-	   floats as its argument */
-
-	const float value = ( func_ptr ) ( arg_list );
-
-	delete[](arg_list);
-	return value;
+  delete[](arg_list);
+  return value;
 }
 
 
 /* Evaluates a value expression */
-float ValExpr::eval_val_expr ( int mesh_i, int mesh_j )
+float
+ValExpr::eval_val_expr ( int mesh_i, int mesh_j )
 {
+  /* Value is a constant, return the float value */
+  if ( type == CONSTANT_TERM_T )
+  {
+    return ( term.constant );
+  }
 
+  /* Value is variable, dereference it */
+  if ( type == PARAM_TERM_T )
+  {
+    switch ( term.param->type )
+    {
+    case P_TYPE_BOOL:
+      return ( float ) ( * ( ( bool* ) ( term.param->engine_val ) ) );
 
-	/* Value is a constant, return the float value */
-	if ( type == CONSTANT_TERM_T )
-	{
-		return ( term.constant );
-	}
+    case P_TYPE_INT:
+      return ( float ) ( * ( ( int* ) ( term.param->engine_val ) ) );
 
-	/* Value is variable, dereference it */
-	if ( type == PARAM_TERM_T )
-	{
-		switch ( term.param->type )
-		{
+    case P_TYPE_DOUBLE:
+      if ( term.param->matrix_flag | ( term.param->flags & P_FLAG_ALWAYS_MATRIX ) )
+      {
+        /* Sanity check the matrix is there... */
+        assert ( term.param->matrix != NULL );
 
-			case P_TYPE_BOOL:
+        /// @slow boolean check could be expensive in this critical (and common) step of evaluation
+        if ( mesh_i >= 0 )
+        {
+          if ( mesh_j >= 0 )
+          {
+            return ( ( ( float** ) term.param->matrix ) [mesh_i][mesh_j] );
+          }
+          else
+          {
+            return ( ( ( float* ) term.param->matrix ) [mesh_i] );
+          }
+        }
+        //assert(mesh_i >=0);
+      }
+      //std::cout << term.param->name << ": " << (*((float*)term.param->engine_val)) << std::endl;
+      return * ( ( float* ) ( term.param->engine_val ) );
 
-
-				return ( float ) ( * ( ( bool* ) ( term.param->engine_val ) ) );
-			case P_TYPE_INT:
-
-
-				return ( float ) ( * ( ( int* ) ( term.param->engine_val ) ) );
-			case P_TYPE_DOUBLE:
-
-
-				if ( term.param->matrix_flag | ( term.param->flags & P_FLAG_ALWAYS_MATRIX ) )
-				{
-
-					/* Sanity check the matrix is there... */
-					assert ( term.param->matrix != NULL );
-
-					/// @slow boolean check could be expensive in this critical (and common) step of evaluation
-					if ( mesh_i >= 0 )
-					{
-						if ( mesh_j >= 0 )
-						{
-							return ( ( ( float** ) term.param->matrix ) [mesh_i][mesh_j] );
-						}
-						else
-						{
-							return ( ( ( float* ) term.param->matrix ) [mesh_i] );
-						}
-					}
-					//assert(mesh_i >=0);
-				}
-				//std::cout << term.param->name << ": " << (*((float*)term.param->engine_val)) << std::endl;
-				return * ( ( float* ) ( term.param->engine_val ) );
-			default:
-				return EVAL_ERROR;
-		}
-	}
-	/* Unknown type, return failure */
-	return PROJECTM_FAILURE;
+    default:
+      return EVAL_ERROR;
+    }
+  }
+  /* Unknown type, return failure */
+  return PROJECTM_FAILURE;
 }
 
 /* Evaluates an expression tree */
-float TreeExpr::eval_tree_expr ( int mesh_i, int mesh_j )
+float
+TreeExpr::eval_tree_expr ( int mesh_i, int mesh_j )
 {
 
-	float left_arg, right_arg;
+  float left_arg, right_arg;
 
-	/* A leaf node, evaluate the general expression. If the expression is null as well, return zero */
-	if ( infix_op == NULL )
-	{
-		if ( gen_expr == NULL )
-			return 0;
-		else
-			return gen_expr->eval_gen_expr ( mesh_i, mesh_j );
-	}
+  /* A leaf node, evaluate the general expression. If the expression is null as well, return zero */
+  if ( infix_op == NULL )
+  {
+    if ( gen_expr == NULL )
+      return 0;
+    else
+      return gen_expr->eval_gen_expr ( mesh_i, mesh_j );
+  }
 
-	/* Otherwise, this node is an infix operator. Evaluate
-	   accordingly */
+  /* Otherwise, this node is an infix operator. Evaluate
+     accordingly */
 
-	assert(left);
-	left_arg = left->eval_tree_expr ( mesh_i, mesh_j );
+  assert(left);
+  left_arg = left->eval_tree_expr ( mesh_i, mesh_j );
 
-	assert(right);
-	right_arg = right->eval_tree_expr ( mesh_i, mesh_j );
+  assert(right);
+  right_arg = right->eval_tree_expr ( mesh_i, mesh_j );
 
 
-	switch ( infix_op->type )
-	{
-		case INFIX_ADD:
-			return ( left_arg + right_arg );
-		case INFIX_MINUS:
-			return ( left_arg - right_arg );
-		case INFIX_MULT:
-			return ( left_arg * right_arg );
-		case INFIX_MOD:
-			if ( ( int ) right_arg == 0 )
-			{
-				return PROJECTM_DIV_BY_ZERO;
-			}
-			return ( ( int ) left_arg % ( int ) right_arg );
-		case INFIX_OR:
-			return ( ( int ) left_arg | ( int ) right_arg );
-		case INFIX_AND:
-			return ( ( int ) left_arg & ( int ) right_arg );
-		case INFIX_DIV:
-			if ( right_arg == 0 )
-			{
-				return MAX_DOUBLE_SIZE;
-			}
-			return ( left_arg / right_arg );
-		default:
-			return EVAL_ERROR;
-	}
+  switch ( infix_op->type )
+  {
+  case INFIX_ADD:
+    return ( left_arg + right_arg );
+  case INFIX_MINUS:
+    return ( left_arg - right_arg );
+  case INFIX_MULT:
+    return ( left_arg * right_arg );
+  case INFIX_MOD:
+    if ( ( int ) right_arg == 0 )
+    {
+      return PROJECTM_DIV_BY_ZERO;
+    }
+    return ( ( int ) left_arg % ( int ) right_arg );
+  case INFIX_OR:
+    return ( ( int ) left_arg | ( int ) right_arg );
+  case INFIX_AND:
+    return ( ( int ) left_arg & ( int ) right_arg );
+  case INFIX_DIV:
+    if ( right_arg == 0 )
+    {
+      return MAX_DOUBLE_SIZE;
+    }
+    return ( left_arg / right_arg );
+  default:
+    return EVAL_ERROR;
+  }
 
-	return EVAL_ERROR;
+  return EVAL_ERROR;
 }
 
 /* Converts a float value to a general expression */
-GenExpr * GenExpr::const_to_expr ( float val )
+GenExpr *
+GenExpr::const_to_expr ( float val )
 {
 
-	GenExpr * gen_expr;
-	ValExpr * val_expr;
-	Term term;
+  GenExpr * gen_expr;
+  ValExpr * val_expr;
+  Term term;
 
-	term.constant = val;
+  term.constant = val;
 
-	if ( ( val_expr = new ValExpr ( CONSTANT_TERM_T, &term ) ) == NULL )
-		return NULL;
+  if ( ( val_expr = new ValExpr ( CONSTANT_TERM_T, &term ) ) == NULL )
+    return NULL;
 
-	gen_expr = new GenExpr ( VAL_T, ( void* ) val_expr );
+  gen_expr = new GenExpr ( VAL_T, ( void* ) val_expr );
 
-	if ( gen_expr == NULL )
-	{
-		delete val_expr;
-	}
+  if ( gen_expr == NULL )
+  {
+    delete val_expr;
+  }
 
-	return gen_expr;
+  return gen_expr;
 }
 
 /* Converts a regular parameter to an expression */
-GenExpr * GenExpr::param_to_expr ( Param * param )
+GenExpr *
+GenExpr::param_to_expr ( Param * param )
 {
 
-	GenExpr * gen_expr = NULL;
-	ValExpr * val_expr = NULL;
-	Term term;
+  GenExpr * gen_expr = NULL;
+  ValExpr * val_expr = NULL;
+  Term term;
 
-	if ( param == NULL )
-		return NULL;
+  if ( param == NULL )
+    return NULL;
 
-	/* This code is still a work in progress. We need
-	   to figure out if the initial condition is used for
-	   each per frame equation or not. I am guessing that
-	   it isn't, and it is thusly implemented this way */
+  /* This code is still a work in progress. We need
+     to figure out if the initial condition is used for
+     each per frame equation or not. I am guessing that
+     it isn't, and it is thusly implemented this way */
 
-	/* Current guess of true behavior (08/01/03) note from carm
-	   First try to use the per_pixel_expr (with cloning)
-	   If it is null however, use the engine variable instead. */
+  /* Current guess of true behavior (08/01/03) note from carm
+     First try to use the per_pixel_expr (with cloning)
+     If it is null however, use the engine variable instead. */
 
-	/* 08/20/03 : Presets are now objects, as well as per pixel equations. This ends up
-	   making the parser handle the case where parameters are essentially per pixel equation
-	   substitutions */
+  /* 08/20/03 : Presets are now objects, as well as per pixel equations. This ends up
+     making the parser handle the case where parameters are essentially per pixel equation
+     substitutions */
 
 
-	term.param = param;
-	if ( ( val_expr = new ValExpr ( PARAM_TERM_T, &term ) ) == NULL )
-		return NULL;
+  term.param = param;
+  if ( ( val_expr = new ValExpr ( PARAM_TERM_T, &term ) ) == NULL )
+    return NULL;
 
-	if ( ( gen_expr = new GenExpr ( VAL_T, ( void* ) val_expr ) ) == NULL )
-	{
-		delete val_expr;
-		return NULL;
-	}
-	return gen_expr;
+  if ( ( gen_expr = new GenExpr ( VAL_T, ( void* ) val_expr ) ) == NULL )
+  {
+    delete val_expr;
+    return NULL;
+  }
+  return gen_expr;
 }
 
 /* Converts a prefix function to an expression */
-GenExpr * GenExpr::prefun_to_expr ( float ( *func_ptr ) ( void * ), GenExpr ** expr_list, int num_args )
+GenExpr *
+GenExpr::prefun_to_expr ( float ( *func_ptr ) ( void * ), GenExpr ** expr_list, int num_args )
 {
 
-	GenExpr * gen_expr;
-	PrefunExpr * prefun_expr;
+  GenExpr * gen_expr;
+  PrefunExpr * prefun_expr;
 
-	prefun_expr = new PrefunExpr();
+  prefun_expr = new PrefunExpr();
 
-	if ( prefun_expr == NULL )
-		return NULL;
+  if ( prefun_expr == NULL )
+    return NULL;
 
-	prefun_expr->num_args = num_args;
-	prefun_expr->func_ptr = ( float ( * ) ( void* ) ) func_ptr;
-	prefun_expr->expr_list = expr_list;
+  prefun_expr->num_args = num_args;
+  prefun_expr->func_ptr = ( float ( * ) ( void* ) ) func_ptr;
+  prefun_expr->expr_list = expr_list;
 
-	gen_expr = new GenExpr ( PREFUN_T, ( void* ) prefun_expr );
+  gen_expr = new GenExpr ( PREFUN_T, ( void* ) prefun_expr );
 
-	if ( gen_expr == NULL )
-		delete prefun_expr;
+  if ( gen_expr == NULL )
+    delete prefun_expr;
 
-	return gen_expr;
+  return gen_expr;
 }
 
 /* Creates a new tree expression */
-TreeExpr::TreeExpr ( InfixOp * _infix_op, GenExpr * _gen_expr, TreeExpr * _left, TreeExpr * _right ) :
-		infix_op ( _infix_op ), gen_expr ( _gen_expr ),
-	left ( _left ), right ( _right ) {}
+TreeExpr::TreeExpr (
+InfixOp   * _infix_op,
+GenExpr   * _gen_expr,
+TreeExpr  * _left,
+TreeExpr  * _right
+)
+  : infix_op ( _infix_op ),
+    gen_expr ( _gen_expr ),
+    left ( _left ),
+    right ( _right )
+{}
 
 
 /* Creates a new value expression */
 ValExpr::ValExpr ( int _type, Term * _term ) :type ( _type )
 {
+  //val_expr->type = _type;
+  term.constant = _term->constant;
+  term.param = _term->param;
 
-
-	//val_expr->type = _type;
-	term.constant = _term->constant;
-	term.param = _term->param;
-
-	//return val_expr;
+  //return val_expr;
 }
 
 /* Creates a new general expression */
 
-GenExpr::GenExpr ( int _type, void * _item ) :type ( _type ), item ( _item ) {}
+GenExpr::GenExpr ( int _type, void * _item )
+  : type ( _type ), item ( _item )
+{}
 
 /* Frees a general expression */
 GenExpr::~GenExpr()
 {
-
-	switch ( type )
-	{
-		case VAL_T:
-			delete ( ( ValExpr* ) item );
-			break;
-		case PREFUN_T:
-			delete ( ( PrefunExpr* ) item );
-			break;
-		case TREE_T:
-			delete ( ( TreeExpr* ) item );
-			break;
-	}
+  switch ( type )
+  {
+  case VAL_T:
+    delete ( ( ValExpr* ) item );
+    break;
+  case PREFUN_T:
+    delete ( ( PrefunExpr* ) item );
+    break;
+  case TREE_T:
+    delete ( ( TreeExpr* ) item );
+    break;
+  }
 }
 
 /* Frees a function in prefix notation */
 PrefunExpr::~PrefunExpr()
 {
+  int i;
 
-	int i;
-
-	/* Free every element in expression list */
-	for ( i = 0 ; i < num_args; i++ )
-	{
-		delete expr_list[i];
-	}
-	free ( expr_list );
+  /* Free every element in expression list */
+  for ( i = 0 ; i < num_args; i++ )
+  {
+    delete expr_list[i];
+  }
+  free ( expr_list );
 }
 
 /* Frees values of type VARIABLE and CONSTANT */
@@ -340,36 +341,34 @@
 /* Frees a tree expression */
 TreeExpr::~TreeExpr()
 {
+  /* free left tree */
+  if ( left != NULL )
+  {
+    delete left;
+  }
 
-	/* free left tree */
-	if ( left != NULL )
-	{
-		delete left;
-	}
+  /* free general expression object */
+  if ( gen_expr != NULL )
+  {
+    delete gen_expr;
+  }
 
-	/* free general expression object */
-	if ( gen_expr != NULL )
-	{
-		delete gen_expr;
-	}
+  /* Note that infix operators are always
+     stored in memory unless the program
+     exits, so we don't remove them here */
 
-	/* Note that infix operators are always
-	   stored in memory unless the program
-	   exits, so we don't remove them here */
-
-	/* free right tree */
-	if ( right != NULL )
-	{
-		delete right;
-	}
+  /* free right tree */
+  if ( right != NULL )
+  {
+    delete right;
+  }
 }
 
 /* Initializes an infix operator */
 InfixOp::InfixOp ( int type, int precedence )
 {
-
-	this->type = type;
-	this->precedence = precedence;
+  this->type = type;
+  this->precedence = precedence;
 }
 
 
diff --git a/src/libprojectM/MilkdropPresetFactory/Expr.hpp b/src/libprojectM/MilkdropPresetFactory/Expr.hpp
index b732531..be6af29 100644
--- a/src/libprojectM/MilkdropPresetFactory/Expr.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/Expr.hpp
@@ -25,13 +25,13 @@
  *
  * $Log$
  */
-
 #ifndef _EXPR_H
 #define _EXPR_H
 
 #include "dlldefs.h"
 #include "CValue.hpp"
 
+
 class Param;
 
 #define CONST_STACK_ELEMENT 0
@@ -39,6 +39,7 @@
 
 #define EVAL_ERROR -1
 
+
 /* Infix Operator Function */
 class InfixOp
 {
@@ -70,7 +71,7 @@
 
   GenExpr( int type, void *item );
   float eval_gen_expr(int mesh_i, int mesh_j);
- 
+
   static GenExpr *const_to_expr( float val );
   static GenExpr *param_to_expr( Param *param );
   static GenExpr *prefun_to_expr( float (*func_ptr)(void *), GenExpr **expr_list, int num_args );
@@ -85,7 +86,7 @@
 
   ~ValExpr();
   ValExpr( int type, Term *term );
-  
+
   float eval_val_expr(int mesh_i, int mesh_j);
 };
 
@@ -100,7 +101,7 @@
   ~TreeExpr();
   TreeExpr( InfixOp *infix_op, GenExpr *gen_expr,
                                   TreeExpr *left, TreeExpr *right );
-  
+
   float eval_tree_expr(int mesh_i, int mesh_j);
 };
 
diff --git a/src/libprojectM/MilkdropPresetFactory/Func.cpp b/src/libprojectM/MilkdropPresetFactory/Func.cpp
index 71a9b29..4385f6f 100644
--- a/src/libprojectM/MilkdropPresetFactory/Func.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/Func.cpp
@@ -30,8 +30,9 @@
 #include "Func.hpp"
 #include <map>
 
+
 Func::Func (const std::string & _name, float (*_func_ptr)(float*), int _num_args):
-	name(_name), func_ptr(_func_ptr), num_args(_num_args) {}
+  name(_name), func_ptr(_func_ptr), num_args(_num_args) {}
 
 /* Frees a function type, real complicated... */
 Func::~Func() {}
diff --git a/src/libprojectM/MilkdropPresetFactory/Func.hpp b/src/libprojectM/MilkdropPresetFactory/Func.hpp
index ae571b7..6a240f4 100644
--- a/src/libprojectM/MilkdropPresetFactory/Func.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/Func.hpp
@@ -32,32 +32,33 @@
 #include "Common.hpp"
 #include <string>
 
+
 /* Function Type */
 class DLLEXPORT Func {
 public:
 
-    /// Create a new function wrapper object
-    /// \param name a name to uniquely identify the function. 
-    /// \param func_ptr a pointer to a function of floating point arguments
-    /// \param num_args the number of floating point arguments this function requires
-    Func(const std::string & name, float (*func_ptr)(float*), int num_args );
+  /// Create a new function wrapper object
+  /// \param name a name to uniquely identify the function.
+  /// \param func_ptr a pointer to a function of floating point arguments
+  /// \param num_args the number of floating point arguments this function requires
+  Func(const std::string & name, float (*func_ptr)(float*), int num_args );
 
-    /* Public Prototypes */
-    ~Func();
+  /* Public Prototypes */
+  ~Func();
 
-	inline const std::string & getName() const {
-		return name;
-	}
+  inline const std::string & getName() const {
+    return name;
+  }
 
-	inline int getNumArgs() const {
-		return num_args;
-	}
+  inline int getNumArgs() const {
+    return num_args;
+  }
 
-    float (*func_ptr)(float*);
-private:	
-    std::string name;
-    int num_args;
+  float (*func_ptr)(float*);
 
+private:
+  std::string name;
+  int num_args;
 };
 
 #endif /** !_FUNC_H */
diff --git a/src/libprojectM/MilkdropPresetFactory/IdlePreset.cpp b/src/libprojectM/MilkdropPresetFactory/IdlePreset.cpp
index 5a48532..4dcd008 100644
--- a/src/libprojectM/MilkdropPresetFactory/IdlePreset.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/IdlePreset.cpp
@@ -2,208 +2,211 @@
 #include <sstream>
 #include <string>
 #include "MilkdropPreset.hpp"
+
+
 const std::string IdlePresets::IDLE_PRESET_NAME
-	("Geiss & Sperl - Feedback (projectM idle HDR mix).milk");
+  ("Geiss & Sperl - Feedback (projectM idle HDR mix).milk");
 
-std::string IdlePresets::presetText() {
 
-std::ostringstream out;
+std::string
+IdlePresets::presetText()
+{
+  std::ostringstream out;
 
-out << "[preset00]\n" <<
-"fRating=2.000000\n" <<
-"fGammaAdj=1.700000\n" <<
-"fDecay=0.940000\n" <<
-"fVideoEchoZoom=1.000000\n" <<
-"fVideoEchoAlpha=0.000000\n" <<
-"nVideoEchoOrientation=0\n" <<
-"nWaveMode=0\n" <<
-"bAdditiveWaves=1\n" <<
-"bWaveDots=0\n" <<
-"bWaveThick=0\n" <<
-"bModWaveAlphaByVolume=0\n" <<
-"bMaximizeWaveColor=0\n" <<
-"bTexWrap=1\n" <<
-"bDarkenCenter=0\n" <<
-"bRedBlueStereo=0\n" <<
-"bBrighten=0\n" <<
-"bDarken=0\n" <<
-"bSolarize=0\n" <<
-"bInvert=0\n" <<
-"fWaveAlpha=0.001000\n" <<
-"fWaveScale=0.010000\n" <<
-"fWaveSmoothing=0.630000\n" <<
-"fWaveParam=-1.000000\n" <<
-"fModWaveAlphaStart=0.710000\n" <<
-"fModWaveAlphaEnd=1.300000\n" <<
-"fWarpAnimSpeed=1.000000\n" <<
-"fWarpScale=1.331000\n" <<
-"fZoomExponent=1.000000\n" <<
-"fShader=0.000000\n" <<
-"zoom=13.290894\n" <<
-"rot=-0.020000\n" <<
-"cx=0.500000\n" <<
-"cy=0.500000\n" <<
-"dx=-0.280000\n" <<
-"dy=-0.320000\n" <<
-"warp=0.010000\n" <<
-"sx=1.000000\n" <<
-"sy=1.000000\n" <<
-"wave_r=0.650000\n" <<
-"wave_g=0.650000\n" <<
-"wave_b=0.650000\n" <<
-"wave_x=0.500000\n" <<
-"wave_y=0.500000\n" <<
-"ob_size=0.000000\n" <<
-"ob_r=0.010000\n" <<
-"ob_g=0.000000\n" <<
-"ob_b=0.000000\n" <<
-"ob_a=1.000000\n" <<
-"ib_size=0.000000\n" <<
-"ib_r=0.950000\n" <<
-"ib_g=0.850000\n" <<
-"ib_b=0.650000\n" <<
-"ib_a=1.000000\n" <<
-"nMotionVectorsX=64.000000\n" <<
-"nMotionVectorsY=0.000000\n" <<
-"mv_dx=0.000000\n" <<
-"mv_dy=0.000000\n" <<
-"mv_l=0.900000\n" <<
-"mv_r=1.000000\n" <<
-"mv_g=1.000000\n" <<
-"mv_b=1.000000\n" <<
-"mv_a=0.000000\n" <<
-"shapecode_3_enabled=1\n" <<
-"shapecode_3_sides=20\n" <<
-"shapecode_3_additive=0\n" <<
-"shapecode_3_thickOutline=0\n" <<
-"shapecode_3_textured=1\n" <<
-"shapecode_3_ImageURL=M.tga\n" <<
-"shapecode_3_x=0.68\n" <<
-"shapecode_3_y=0.5\n" <<
-"shapecode_3_rad=0.41222\n" <<
-"shapecode_3_ang=0\n" <<
-"shapecode_3_tex_ang=0\n" <<
-"shapecode_3_tex_zoom=0.71\n" <<
-"shapecode_3_r=1\n" <<
-"shapecode_3_g=1\n" <<
-"shapecode_3_b=1\n" <<
-"shapecode_3_a=1\n" <<
-"shapecode_3_r2=1\n" <<
-"shapecode_3_g2=1\n" <<
-"shapecode_3_b2=1\n" <<
-"shapecode_3_a2=1\n" <<
-"shapecode_3_border_r=0\n" <<
-"shapecode_3_border_g=0\n" <<
-"shapecode_3_border_b=0\n" <<
-"shapecode_3_border_a=0\n" <<
-"shape_3_per_frame1=x = x + q1;\n" <<
-"shape_3_per_frame2=y = y + q2;\n" <<
-"shape_3_per_frame3=r =0.5 + 0.5*sin(q8*0.613 + 1);\n" <<
-"shape_3_per_frame4=g = 0.5 + 0.5*sin(q8*0.763 + 2);\n" <<
-"shape_3_per_frame5=b = 0.5 + 0.5*sin(q8*0.771 + 5);\n" <<
-"shape_3_per_frame6=r2 = 0.5 + 0.5*sin(q8*0.635 + 4);\n" <<
-"shape_3_per_frame7=g2 = 0.5 + 0.5*sin(q8*0.616+ 1);\n" <<
-"shape_3_per_frame8=b2 = 0.5 + 0.5*sin(q8*0.538 + 3);\n" <<
-"shapecode_4_enabled=1\n" <<
-"shapecode_4_sides=4\n" <<
-"shapecode_4_additive=0\n" <<
-"shapecode_4_thickOutline=0\n" <<
-"shapecode_4_textured=1\n" <<
-"shapecode_4_ImageURL=headphones.tga\n" <<
-"shapecode_4_x=0.68\n" <<
-"shapecode_4_y=0.58\n" <<
-"shapecode_4_rad=0.6\n" <<
-"shapecode_4_ang=0\n" <<
-"shapecode_4_tex_ang=0\n" <<
-"shapecode_4_tex_zoom=0.71\n" <<
-"shapecode_4_r=1\n" <<
-"shapecode_4_g=1\n" <<
-"shapecode_4_b=1\n" <<
-"shapecode_4_a=1\n" <<
-"shapecode_4_r2=1\n" <<
-"shapecode_4_g2=1\n" <<
-"shapecode_4_b2=1\n" <<
-"shapecode_4_a2=1\n" <<
-"shapecode_4_border_r=0\n" <<
-"shapecode_4_border_g=0\n" <<
-"shapecode_4_border_b=0\n" <<
-"shapecode_4_border_a=0\n" <<
-"shape_4_per_frame1=x = x + q1;\n" <<
-"shape_4_per_frame2=y = y + q2;\n" <<
-"shape_4_per_frame3=rad = rad + bass * 0.1;\n" <<
-"shape_4_per_frame4=a = q3;\n" <<
-"shape_4_per_frame5=a2 = q3;\n" <<
-"shapecode_6_enabled=1\n" <<
-"shapecode_6_sides=4\n" <<
-"shapecode_6_additive=0\n" <<
-"shapecode_6_thickOutline=0\n" <<
-"shapecode_6_textured=1\n" <<
-"shapecode_6_ImageURL=project.tga\n" <<
-"shapecode_6_x=0.38\n" <<
-"shapecode_6_y=0.435\n" <<
-"shapecode_6_rad=0.8\n" <<
-"shapecode_6_ang=0\n" <<
-"shapecode_6_tex_ang=0\n" <<
-"shapecode_6_tex_zoom=0.71\n" <<
-"shapecode_6_r=1\n" <<
-"shapecode_6_g=1\n" <<
-"shapecode_6_b=1\n" <<
-"shapecode_6_a=1\n" <<
-"shapecode_6_r2=1\n" <<
-"shapecode_6_g2=1\n" <<
-"shapecode_6_b2=1\n" <<
-"shapecode_6_a2=1\n" <<
-"shapecode_6_border_r=0\n" <<
-"shapecode_6_border_g=0\n" <<
-"shapecode_6_border_b=0\n" <<
-"shapecode_6_border_a=0\n" <<
-"shape_6_per_frame1=x = x + q1;\n" <<
-"shape_6_per_frame2=y = y + q2;\n" <<
-"shape_6_per_frame3=a = q3;\n" <<
-"shape_6_per_frame4=a2 = q3;\n" <<
-"per_frame_1=ob_r = 0.5 + 0.4*sin(time*1.324);\n" <<
-"per_frame_2=ob_g = 0.5 + 0.4*cos(time*1.371);\n" <<
-"per_frame_3=ob_b = 0.5+0.4*sin(2.332*time);\n" <<
-"per_frame_4=ib_r = 0.5 + 0.25*sin(time*1.424);\n" <<
-"per_frame_5=ib_g = 0.25 + 0.25*cos(time*1.871);\n" <<
-"per_frame_6=ib_b = 1-ob_b;\n" <<
-"per_frame_7=volume = 0.15*(bass+bass_att+treb+treb_att+mid+mid_att);\n" <<
-"per_frame_8=xamptarg = if(equal(frame%15,0),min(0.5*volume*bass_att,0.5),xamptarg);\n" <<
-"per_frame_9=xamp = xamp + 0.5*(xamptarg-xamp);\n" <<
-"per_frame_10=xdir = if(above(abs(xpos),xamp),-sign(xpos),if(below(abs(xspeed),0.1),2*above(xpos,0)-1,xdir));\n" <<
-"per_frame_11=xaccel = xdir*xamp - xpos - xspeed*0.055*below(abs(xpos),xamp);\n" <<
-"per_frame_12=xspeed = xspeed + xdir*xamp - xpos - xspeed*0.055*below(abs(xpos),xamp);\n" <<
-"per_frame_13=xpos = xpos + 0.001*xspeed;\n" <<
-"per_frame_14=dx = xpos*0.05;\n" <<
-"per_frame_15=yamptarg = if(equal(frame%15,0),min(0.3*volume*treb_att,0.5),yamptarg);\n" <<
-"per_frame_16=yamp = yamp + 0.5*(yamptarg-yamp);\n" <<
-"per_frame_17=ydir = if(above(abs(ypos),yamp),-sign(ypos),if(below(abs(yspeed),0.1),2*above(ypos,0)-1,ydir));\n" <<
-"per_frame_18=yaccel = ydir*yamp - ypos - yspeed*0.055*below(abs(ypos),yamp);\n" <<
-"per_frame_19=yspeed = yspeed + ydir*yamp - ypos - yspeed*0.055*below(abs(ypos),yamp);\n" <<
-"per_frame_20=ypos = ypos + 0.001*yspeed;\n" <<
-"per_frame_21=dy = ypos*0.05;\n" <<
-"per_frame_22=wave_a = 0;\n" <<
-"per_frame_23=q8 = oldq8 + 0.0003*(pow(1+1.2*bass+0.4*bass_att+0.1*treb+0.1*treb_att+0.1*mid+0.1*mid_att,6)/fps);\n" <<
-"per_frame_24=oldq8 = q8;\n" <<
-"per_frame_25=q7 = 0.003*(pow(1+1.2*bass+0.4*bass_att+0.1*treb+0.1*treb_att+0.1*mid+0.1*mid_att,6)/fps);\n" <<
-"per_frame_26=rot = 0.4 + 1.5*sin(time*0.273) + 0.4*sin(time*0.379+3);\n" <<
-"per_frame_27=q1 = 0.05*sin(time*1.14);\n" <<
-"per_frame_28=q2 = 0.03*sin(time*0.93+2);\n" <<
-"per_frame_29=q3 = if(above(frame,60),1, frame/60.0);\n" <<
-"per_frame_30=oldq8 = if(above(oldq8,1000),0,oldq8);\n" <<
-"per_pixel_1=zoom =( log(sqrt(2)-rad) -0.24)*1;\n";
+  out << "[preset00]\n"
+      << "fRating=2.000000\n"
+      << "fGammaAdj=1.700000\n"
+      << "fDecay=0.940000\n"
+      << "fVideoEchoZoom=1.000000\n"
+      << "fVideoEchoAlpha=0.000000\n"
+      << "nVideoEchoOrientation=0\n"
+      << "nWaveMode=0\n"
+      << "bAdditiveWaves=1\n"
+      << "bWaveDots=0\n"
+      << "bWaveThick=0\n"
+      << "bModWaveAlphaByVolume=0\n"
+      << "bMaximizeWaveColor=0\n"
+      << "bTexWrap=1\n"
+      << "bDarkenCenter=0\n"
+      << "bRedBlueStereo=0\n"
+      << "bBrighten=0\n"
+      << "bDarken=0\n"
+      << "bSolarize=0\n"
+      << "bInvert=0\n"
+      << "fWaveAlpha=0.001000\n"
+      << "fWaveScale=0.010000\n"
+      << "fWaveSmoothing=0.630000\n"
+      << "fWaveParam=-1.000000\n"
+      << "fModWaveAlphaStart=0.710000\n"
+      << "fModWaveAlphaEnd=1.300000\n"
+      << "fWarpAnimSpeed=1.000000\n"
+      << "fWarpScale=1.331000\n"
+      << "fZoomExponent=1.000000\n"
+      << "fShader=0.000000\n"
+      << "zoom=13.290894\n"
+      << "rot=-0.020000\n"
+      << "cx=0.500000\n"
+      << "cy=0.500000\n"
+      << "dx=-0.280000\n"
+      << "dy=-0.320000\n"
+      << "warp=0.010000\n"
+      << "sx=1.000000\n"
+      << "sy=1.000000\n"
+      << "wave_r=0.650000\n"
+      << "wave_g=0.650000\n"
+      << "wave_b=0.650000\n"
+      << "wave_x=0.500000\n"
+      << "wave_y=0.500000\n"
+      << "ob_size=0.000000\n"
+      << "ob_r=0.010000\n"
+      << "ob_g=0.000000\n"
+      << "ob_b=0.000000\n"
+      << "ob_a=1.000000\n"
+      << "ib_size=0.000000\n"
+      << "ib_r=0.950000\n"
+      << "ib_g=0.850000\n"
+      << "ib_b=0.650000\n"
+      << "ib_a=1.000000\n"
+      << "nMotionVectorsX=64.000000\n"
+      << "nMotionVectorsY=0.000000\n"
+      << "mv_dx=0.000000\n"
+      << "mv_dy=0.000000\n"
+      << "mv_l=0.900000\n"
+      << "mv_r=1.000000\n"
+      << "mv_g=1.000000\n"
+      << "mv_b=1.000000\n"
+      << "mv_a=0.000000\n"
+      << "shapecode_3_enabled=1\n"
+      << "shapecode_3_sides=20\n"
+      << "shapecode_3_additive=0\n"
+      << "shapecode_3_thickOutline=0\n"
+      << "shapecode_3_textured=1\n"
+      << "shapecode_3_ImageURL=M.tga\n"
+      << "shapecode_3_x=0.68\n"
+      << "shapecode_3_y=0.5\n"
+      << "shapecode_3_rad=0.41222\n"
+      << "shapecode_3_ang=0\n"
+      << "shapecode_3_tex_ang=0\n"
+      << "shapecode_3_tex_zoom=0.71\n"
+      << "shapecode_3_r=1\n"
+      << "shapecode_3_g=1\n"
+      << "shapecode_3_b=1\n"
+      << "shapecode_3_a=1\n"
+      << "shapecode_3_r2=1\n"
+      << "shapecode_3_g2=1\n"
+      << "shapecode_3_b2=1\n"
+      << "shapecode_3_a2=1\n"
+      << "shapecode_3_border_r=0\n"
+      << "shapecode_3_border_g=0\n"
+      << "shapecode_3_border_b=0\n"
+      << "shapecode_3_border_a=0\n"
+      << "shape_3_per_frame1=x = x + q1;\n"
+      << "shape_3_per_frame2=y = y + q2;\n"
+      << "shape_3_per_frame3=r =0.5 + 0.5*sin(q8*0.613 + 1);\n"
+      << "shape_3_per_frame4=g = 0.5 + 0.5*sin(q8*0.763 + 2);\n"
+      << "shape_3_per_frame5=b = 0.5 + 0.5*sin(q8*0.771 + 5);\n"
+      << "shape_3_per_frame6=r2 = 0.5 + 0.5*sin(q8*0.635 + 4);\n"
+      << "shape_3_per_frame7=g2 = 0.5 + 0.5*sin(q8*0.616+ 1);\n"
+      << "shape_3_per_frame8=b2 = 0.5 + 0.5*sin(q8*0.538 + 3);\n"
+      << "shapecode_4_enabled=1\n"
+      << "shapecode_4_sides=4\n"
+      << "shapecode_4_additive=0\n"
+      << "shapecode_4_thickOutline=0\n"
+      << "shapecode_4_textured=1\n"
+      << "shapecode_4_ImageURL=headphones.tga\n"
+      << "shapecode_4_x=0.68\n"
+      << "shapecode_4_y=0.58\n"
+      << "shapecode_4_rad=0.6\n"
+      << "shapecode_4_ang=0\n"
+      << "shapecode_4_tex_ang=0\n"
+      << "shapecode_4_tex_zoom=0.71\n"
+      << "shapecode_4_r=1\n"
+      << "shapecode_4_g=1\n"
+      << "shapecode_4_b=1\n"
+      << "shapecode_4_a=1\n"
+      << "shapecode_4_r2=1\n"
+      << "shapecode_4_g2=1\n"
+      << "shapecode_4_b2=1\n"
+      << "shapecode_4_a2=1\n"
+      << "shapecode_4_border_r=0\n"
+      << "shapecode_4_border_g=0\n"
+      << "shapecode_4_border_b=0\n"
+      << "shapecode_4_border_a=0\n"
+      << "shape_4_per_frame1=x = x + q1;\n"
+      << "shape_4_per_frame2=y = y + q2;\n"
+      << "shape_4_per_frame3=rad = rad + bass * 0.1;\n"
+      << "shape_4_per_frame4=a = q3;\n"
+      << "shape_4_per_frame5=a2 = q3;\n"
+      << "shapecode_6_enabled=1\n"
+      << "shapecode_6_sides=4\n"
+      << "shapecode_6_additive=0\n"
+      << "shapecode_6_thickOutline=0\n"
+      << "shapecode_6_textured=1\n"
+      << "shapecode_6_ImageURL=project.tga\n"
+      << "shapecode_6_x=0.38\n"
+      << "shapecode_6_y=0.435\n"
+      << "shapecode_6_rad=0.8\n"
+      << "shapecode_6_ang=0\n"
+      << "shapecode_6_tex_ang=0\n"
+      << "shapecode_6_tex_zoom=0.71\n"
+      << "shapecode_6_r=1\n"
+      << "shapecode_6_g=1\n"
+      << "shapecode_6_b=1\n"
+      << "shapecode_6_a=1\n"
+      << "shapecode_6_r2=1\n"
+      << "shapecode_6_g2=1\n"
+      << "shapecode_6_b2=1\n"
+      << "shapecode_6_a2=1\n"
+      << "shapecode_6_border_r=0\n"
+      << "shapecode_6_border_g=0\n"
+      << "shapecode_6_border_b=0\n"
+      << "shapecode_6_border_a=0\n"
+      << "shape_6_per_frame1=x = x + q1;\n"
+      << "shape_6_per_frame2=y = y + q2;\n"
+      << "shape_6_per_frame3=a = q3;\n"
+      << "shape_6_per_frame4=a2 = q3;\n"
+      << "per_frame_1=ob_r = 0.5 + 0.4*sin(time*1.324);\n"
+      << "per_frame_2=ob_g = 0.5 + 0.4*cos(time*1.371);\n"
+      << "per_frame_3=ob_b = 0.5+0.4*sin(2.332*time);\n"
+      << "per_frame_4=ib_r = 0.5 + 0.25*sin(time*1.424);\n"
+      << "per_frame_5=ib_g = 0.25 + 0.25*cos(time*1.871);\n"
+      << "per_frame_6=ib_b = 1-ob_b;\n"
+      << "per_frame_7=volume = 0.15*(bass+bass_att+treb+treb_att+mid+mid_att);\n"
+      << "per_frame_8=xamptarg = if(equal(frame%15,0),min(0.5*volume*bass_att,0.5),xamptarg);\n"
+      << "per_frame_9=xamp = xamp + 0.5*(xamptarg-xamp);\n"
+      << "per_frame_10=xdir = if(above(abs(xpos),xamp),-sign(xpos),if(below(abs(xspeed),0.1),2*above(xpos,0)-1,xdir));\n"
+      << "per_frame_11=xaccel = xdir*xamp - xpos - xspeed*0.055*below(abs(xpos),xamp);\n"
+      << "per_frame_12=xspeed = xspeed + xdir*xamp - xpos - xspeed*0.055*below(abs(xpos),xamp);\n"
+      << "per_frame_13=xpos = xpos + 0.001*xspeed;\n"
+      << "per_frame_14=dx = xpos*0.05;\n"
+      << "per_frame_15=yamptarg = if(equal(frame%15,0),min(0.3*volume*treb_att,0.5),yamptarg);\n"
+      << "per_frame_16=yamp = yamp + 0.5*(yamptarg-yamp);\n"
+      << "per_frame_17=ydir = if(above(abs(ypos),yamp),-sign(ypos),if(below(abs(yspeed),0.1),2*above(ypos,0)-1,ydir));\n"
+      << "per_frame_18=yaccel = ydir*yamp - ypos - yspeed*0.055*below(abs(ypos),yamp);\n"
+      << "per_frame_19=yspeed = yspeed + ydir*yamp - ypos - yspeed*0.055*below(abs(ypos),yamp);\n"
+      << "per_frame_20=ypos = ypos + 0.001*yspeed;\n"
+      << "per_frame_21=dy = ypos*0.05;\n"
+      << "per_frame_22=wave_a = 0;\n"
+      << "per_frame_23=q8 = oldq8 + 0.0003*(pow(1+1.2*bass+0.4*bass_att+0.1*treb+0.1*treb_att+0.1*mid+0.1*mid_att,6)/fps);\n"
+      << "per_frame_24=oldq8 = q8;\n"
+      << "per_frame_25=q7 = 0.003*(pow(1+1.2*bass+0.4*bass_att+0.1*treb+0.1*treb_att+0.1*mid+0.1*mid_att,6)/fps);\n"
+      << "per_frame_26=rot = 0.4 + 1.5*sin(time*0.273) + 0.4*sin(time*0.379+3);\n"
+      << "per_frame_27=q1 = 0.05*sin(time*1.14);\n"
+      << "per_frame_28=q2 = 0.03*sin(time*0.93+2);\n"
+      << "per_frame_29=q3 = if(above(frame,60),1, frame/60.0);\n"
+      << "per_frame_30=oldq8 = if(above(oldq8,1000),0,oldq8);\n"
+      << "per_pixel_1=zoom =( log(sqrt(2)-rad) -0.24)*1;\n";
 
-return out.str();
-
+  return out.str();
 }
 
-std::auto_ptr<Preset> IdlePresets::allocate(const std::string & name, PresetOutputs & presetOutputs)
+std::auto_ptr<Preset>
+IdlePresets::allocate(const std::string & name, PresetOutputs & presetOutputs)
 {
-
   if (name == IDLE_PRESET_NAME) {
-  	std::istringstream in(presetText());
-  	return std::auto_ptr<Preset>(new MilkdropPreset(in, IDLE_PRESET_NAME, presetOutputs));
+    std::istringstream in(presetText());
+    return std::auto_ptr<Preset>(new MilkdropPreset(in, IDLE_PRESET_NAME, presetOutputs));
   }
   else
-	return std::auto_ptr<Preset>(0);
+    return std::auto_ptr<Preset>(0);
 }
diff --git a/src/libprojectM/MilkdropPresetFactory/IdlePreset.hpp b/src/libprojectM/MilkdropPresetFactory/IdlePreset.hpp
index 3231d43..31bb01a 100644
--- a/src/libprojectM/MilkdropPresetFactory/IdlePreset.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/IdlePreset.hpp
@@ -3,18 +3,20 @@
 #include <memory>
 #include <string>
 
+
 class PresetOutputs;
 class Preset;
 /// A preset that does not depend on the file system to be loaded. This allows projectM to render
 /// something (ie. self indulgent project advertising) even when no valid preset directory is found.
 class IdlePresets {
 
-  public:
-	/// Allocate a new idle preset instance
-	/// \returns a newly allocated auto pointer of an idle preset instance
-	static std::auto_ptr<Preset> allocate(const std::string & path, PresetOutputs & outputs);
-  private:
-	static std::string presetText();
-	static const std::string IDLE_PRESET_NAME;
+public:
+  /// Allocate a new idle preset instance
+  /// \returns a newly allocated auto pointer of an idle preset instance
+  static std::auto_ptr<Preset> allocate(const std::string & path, PresetOutputs & outputs);
+private:
+  static std::string presetText();
+  static const std::string IDLE_PRESET_NAME;
 };
+
 #endif
diff --git a/src/libprojectM/MilkdropPresetFactory/InitCond.cpp b/src/libprojectM/MilkdropPresetFactory/InitCond.cpp
index 2dae471..e171ce5 100644
--- a/src/libprojectM/MilkdropPresetFactory/InitCond.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/InitCond.cpp
@@ -36,15 +36,16 @@
 #include <cassert>
 #include <iostream>
 
+
 char InitCond::init_cond_string_buffer[STRING_BUFFER_SIZE];
 int InitCond::init_cond_string_buffer_index = 0;
 
+
 /* Creates a new initial condition */
-InitCond::InitCond( Param * _param, CValue _init_val ):param(_param), init_val(_init_val) {
-
-
+InitCond::InitCond( Param * _param, CValue _init_val ):param(_param), init_val(_init_val)
+{
   //  std::cerr <<  "InitCond::InitCond: " << this->param->name << std::endl;
- 
+
   assert(param);
   assert(param->engine_val);
 }
@@ -52,55 +53,55 @@
 /* Frees initial condition structure */
 InitCond::~InitCond() {}
 
-void InitCond::evaluate() 
+void
+InitCond::evaluate()
 {
   evaluate(false);
 }
 
 /* Evaluate an initial conditon */
-void InitCond::evaluate(bool evalUser) {
+void
+InitCond::evaluate(bool evalUser)
+{
+  assert(this);
+  assert(param);
 
+  if (param->flags & P_FLAG_USERDEF && !evalUser)
+    return;
 
-
-   assert(this);
-   assert(param);
-
-if (param->flags & P_FLAG_USERDEF && !evalUser)
-	return;
-
-   /* Set matrix flag to zero. This ensures
-     its constant value will be used rather than a matrix value 
+  /* Set matrix flag to zero. This ensures
+     its constant value will be used rather than a matrix value
   */
-param->matrix_flag = false;
-  
+  param->matrix_flag = false;
+
   /* Parameter is of boolean type, either true/false */
-  
+
   if (param->type == P_TYPE_BOOL) {
 
-    //        printf( "init_cond: %s = %d (TYPE BOOL)\n", param->name.c_str(), init_val.bool_val); 
-	//std::cerr << "[InitCond] param is a boolean of with name " 
-	//	<< param->name << std::endl;
+    //        printf( "init_cond: %s = %d (TYPE BOOL)\n", param->name.c_str(), init_val.bool_val);
+    //std::cerr << "[InitCond] param is a boolean of with name "
+    //  << param->name << std::endl;
 
-	assert(param->engine_val);
+    assert(param->engine_val);
 
-	 *((bool*)param->engine_val) = init_val.bool_val;
+    *((bool*)param->engine_val) = init_val.bool_val;
 
-     return;
+    return;
   }
-  
+
   /* Parameter is an integer type, just like C */
-  
+
   if ( param->type == P_TYPE_INT) {
- 	assert(param->engine_val);
-	 *((int*)param->engine_val) = init_val.int_val;
-     return;
+    assert(param->engine_val);
+    *((int*)param->engine_val) = init_val.int_val;
+    return;
   }
 
   /* Parameter is of a float type, just like C */
 
   if (param->type == P_TYPE_DOUBLE) {
-	assert(param->engine_val);
-	*((float*)param->engine_val) = init_val.float_val;
+    assert(param->engine_val);
+    *((float*)param->engine_val) = init_val.float_val;
     return;
   }
 
@@ -109,39 +110,39 @@
 }
 
 /* WIP */
-void InitCond::init_cond_to_string() {
-	
-	int string_length;
-	char string[MAX_TOKEN_SIZE];
-	
-	/* Create a string "param_name=val" */
-	switch (param->type) {
-		
-		case P_TYPE_BOOL:
-			sprintf(string, "%s=%d\n", param->name.c_str(), init_val.bool_val);
-			break; 
-		case P_TYPE_INT:
-			sprintf(string, "%s=%d\n", param->name.c_str(), init_val.int_val);
-			break;
-		case P_TYPE_DOUBLE:
-			sprintf(string, "%s=%f\n", param->name.c_str(), init_val.float_val);
-			break;
-		default:
-			return;
-	}
-		
-	/* Compute the length of the string */
-	string_length = strlen(string);
-	
-	/* Buffer overflow check */
-	if ((init_cond_string_buffer_index + string_length + 1)  > (STRING_BUFFER_SIZE - 1))
-		return;
-	
-	/* Copy the string into the initial condition string buffer */	
-	strncpy(init_cond_string_buffer + init_cond_string_buffer_index, string, string_length);
-	
-	/* Increment the string buffer, offset by one for the null terminator, which will be
-	   overwritten by the next call to this function */
-	init_cond_string_buffer_index+= string_length + 1;
-}
+void
+InitCond::init_cond_to_string()
+{
+  int   string_length;
+  char  string[MAX_TOKEN_SIZE];
 
+  /* Create a string "param_name=val" */
+  switch (param->type) {
+
+  case P_TYPE_BOOL:
+    sprintf(string, "%s=%d\n", param->name.c_str(), init_val.bool_val);
+    break;
+  case P_TYPE_INT:
+    sprintf(string, "%s=%d\n", param->name.c_str(), init_val.int_val);
+    break;
+  case P_TYPE_DOUBLE:
+    sprintf(string, "%s=%f\n", param->name.c_str(), init_val.float_val);
+    break;
+  default:
+    return;
+  }
+
+  /* Compute the length of the string */
+  string_length = strlen(string);
+
+  /* Buffer overflow check */
+  if ((init_cond_string_buffer_index + string_length + 1)  > (STRING_BUFFER_SIZE - 1))
+    return;
+
+  /* Copy the string into the initial condition string buffer */
+  strncpy(init_cond_string_buffer + init_cond_string_buffer_index, string, string_length);
+
+  /* Increment the string buffer, offset by one for the null terminator, which will be
+     overwritten by the next call to this function */
+  init_cond_string_buffer_index+= string_length + 1;
+}
diff --git a/src/libprojectM/MilkdropPresetFactory/InitCond.hpp b/src/libprojectM/MilkdropPresetFactory/InitCond.hpp
index a4b124b..43717b3 100644
--- a/src/libprojectM/MilkdropPresetFactory/InitCond.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/InitCond.hpp
@@ -39,22 +39,23 @@
 class Param;
 #include <map>
 
+
 class InitCond {
 public:
-    Param *param;
-    CValue init_val;
+  Param *param;
+  CValue init_val;
 
-    static char init_cond_string_buffer[STRING_BUFFER_SIZE];
-    static int init_cond_string_buffer_index;
+  static char init_cond_string_buffer[STRING_BUFFER_SIZE];
+  static int init_cond_string_buffer_index;
 
-    InitCond( Param * param, CValue init_val);
-    ~InitCond();
-    void evaluate();  //Wrapper around following declaration
-    void evaluate(bool evalUser);
+  InitCond( Param * param, CValue init_val);
+  ~InitCond();
+  void evaluate();  //Wrapper around following declaration
+  void evaluate(bool evalUser);
 
-    void init_cond_to_string();
-    void write_init();
-  };
+  void init_cond_to_string();
+  void write_init();
+};
 
 
 #endif /** !_INIT_COND_H */
diff --git a/src/libprojectM/MilkdropPresetFactory/InitCondUtils.hpp b/src/libprojectM/MilkdropPresetFactory/InitCondUtils.hpp
index 2186199..493d249 100644
--- a/src/libprojectM/MilkdropPresetFactory/InitCondUtils.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/InitCondUtils.hpp
@@ -5,75 +5,78 @@
 #include <iostream>
 #include <stdlib.h>
 
+
 namespace InitCondUtils {
+
 class LoadUnspecInitCond {
-	public:
+public:
 
-	LoadUnspecInitCond(std::map<std::string,InitCond*> & initCondTree, std::map<std::string,InitCond*> & perFrameInitEqnTree):
-		 m_initCondTree(initCondTree), m_perFrameInitEqnTree(perFrameInitEqnTree) {}
+  LoadUnspecInitCond(std::map<std::string,InitCond*> & initCondTree, std::map<std::string,InitCond*> & perFrameInitEqnTree):
+    m_initCondTree(initCondTree), m_perFrameInitEqnTree(perFrameInitEqnTree) {}
 
-	void operator()(Param * param);
+  void operator()(Param * param);
 
-	private:
-		std::map<std::string,InitCond*> & m_initCondTree;
-		std::map<std::string,InitCond*> & m_perFrameInitEqnTree;
+private:
+  std::map<std::string,InitCond*> & m_initCondTree;
+  std::map<std::string,InitCond*> & m_perFrameInitEqnTree;
 };
 
 
-inline void LoadUnspecInitCond::operator() (Param * param) {
+inline void
+LoadUnspecInitCond::operator() (Param * param)
+{
+  InitCond  * init_cond = 0;
+  CValue    init_val;
 
-    InitCond * init_cond = 0;
-    CValue init_val;
-
-    assert(param);
-    assert(param->engine_val);
+  assert(param);
+  assert(param->engine_val);
 
 
-    /* Don't count these parameters as initial conditions */
-    if (param->flags & P_FLAG_READONLY)
-        return;
-    if (param->flags & P_FLAG_QVAR)
-        return;
-//    if (param->flags & P_FLAG_TVAR)
- //       return;
-    if (param->flags & P_FLAG_USERDEF)
-        return;
+  /* Don't count these parameters as initial conditions */
+  if (param->flags & P_FLAG_READONLY)
+    return;
+  if (param->flags & P_FLAG_QVAR)
+    return;
+  //if (param->flags & P_FLAG_TVAR)
+  //  return;
+  if (param->flags & P_FLAG_USERDEF)
+    return;
 
-    /* If initial condition was not defined by the preset file, force a default one
-       with the following code */
+  /* If initial condition was not defined by the preset file, force a default one
+     with the following code */
 
-    if (m_initCondTree.find(param->name) == m_initCondTree.end()) {
+  if (m_initCondTree.find(param->name) == m_initCondTree.end()) {
 
-        /* Make sure initial condition does not exist in the set of per frame initial equations */
-	if (m_perFrameInitEqnTree.find(param->name) != m_perFrameInitEqnTree.end())
-		return;
+    /* Make sure initial condition does not exist in the set of per frame initial equations */
+    if (m_perFrameInitEqnTree.find(param->name) != m_perFrameInitEqnTree.end())
+      return;
 
-	// Set an initial vialue via correct union member
-        if (param->type == P_TYPE_BOOL)
-            init_val.bool_val = param->default_init_val.bool_val;
-        else if (param->type == P_TYPE_INT)
-            init_val.int_val = param->default_init_val.int_val;
+    // Set an initial vialue via correct union member
+    if (param->type == P_TYPE_BOOL)
+      init_val.bool_val = param->default_init_val.bool_val;
+    else if (param->type == P_TYPE_INT)
+      init_val.int_val = param->default_init_val.int_val;
 
-        else if (param->type == P_TYPE_DOUBLE) {
-           		init_val.float_val = param->default_init_val.float_val;
-	}
+    else if (param->type == P_TYPE_DOUBLE) {
+      init_val.float_val = param->default_init_val.float_val;
+    }
 
-        //printf("%s\n", param->name);
-        /* Create new initial condition */
-	//std::cerr << "[InitCondUtils] creating an unspecified initial condition of name " << param->name << std::endl;
-        if ((init_cond = new InitCond(param, init_val)) == NULL) {
-	    abort();
-        }
+    //printf("%s\n", param->name);
+    /* Create new initial condition */
+    //std::cerr << "[InitCondUtils] creating an unspecified initial condition of name " << param->name << std::endl;
+    if ((init_cond = new InitCond(param, init_val)) == NULL) {
+      abort();
+    }
 
-        /* Insert the initial condition into this presets tree */
-	std::pair<std::map<std::string, InitCond*>::iterator, bool> inserteePair =
-		m_initCondTree.insert(std::make_pair(init_cond->param->name, init_cond));
-	assert(inserteePair.second);
-	assert(inserteePair.first->second);
-    } else
-	assert(m_initCondTree.find(param->name)->second);
+    /* Insert the initial condition into this presets tree */
+    std::pair<std::map<std::string, InitCond*>::iterator, bool> inserteePair =
+    m_initCondTree.insert(std::make_pair(init_cond->param->name, init_cond));
 
-
+    assert(inserteePair.second);
+    assert(inserteePair.first->second);
+  } else
+    assert(m_initCondTree.find(param->name)->second);
 }
-}
+
+}   /*  namespace InitCondUtils  */
 #endif
diff --git a/src/libprojectM/MilkdropPresetFactory/MilkdropPreset.cpp b/src/libprojectM/MilkdropPresetFactory/MilkdropPreset.cpp
index d6acc7b..8f2d429 100644
--- a/src/libprojectM/MilkdropPresetFactory/MilkdropPreset.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/MilkdropPreset.cpp
@@ -18,7 +18,6 @@
  * See 'LICENSE.txt' included within this release
  *
  */
-
 #include <cstdio>
 #include <cstring>
 #include <cstdlib>
@@ -40,29 +39,27 @@
 
 #include "PresetFrameIO.hpp"
 
-MilkdropPreset::MilkdropPreset(std::istream & in, const std::string & presetName,  PresetOutputs & presetOutputs):
-	Preset(presetName),
-    	builtinParams(_presetInputs, presetOutputs),
-    	_presetOutputs(presetOutputs)
+
+MilkdropPreset::MilkdropPreset(std::istream & in, const std::string & presetName,  PresetOutputs & presetOutputs)
+  : Preset(presetName),
+    builtinParams(_presetInputs, presetOutputs),
+    _presetOutputs(presetOutputs)
 {
   initialize(in);
-
 }
 
-MilkdropPreset::MilkdropPreset(const std::string & absoluteFilePath, const std::string & presetName, PresetOutputs & presetOutputs):
-	Preset(presetName),
+MilkdropPreset::MilkdropPreset (const std::string & absoluteFilePath, const std::string & presetName, PresetOutputs & presetOutputs)
+  : Preset(presetName),
     builtinParams(_presetInputs, presetOutputs),
     _absoluteFilePath(absoluteFilePath),
     _presetOutputs(presetOutputs),
     _filename(parseFilename(absoluteFilePath))
 {
-
   initialize(absoluteFilePath);
-
 }
+
 MilkdropPreset::~MilkdropPreset()
 {
-
   traverse<TraverseFunctors::Delete<InitCond> >(init_cond_tree);
 
   traverse<TraverseFunctors::Delete<InitCond> >(per_frame_init_eqn_tree);
@@ -73,38 +70,41 @@
 
   traverse<TraverseFunctors::Delete<Param> >(user_param_tree);
 
-  /// Testing deletion of render items by the preset. would be nice if it worked, 
+  /// Testing deletion of render items by the preset. would be nice if it worked,
   /// and seems to be working if you use a mutex on the preset switching.
-  
-  for (PresetOutputs::cwave_container::iterator pos = customWaves.begin(); 
-	pos != customWaves.end(); ++pos ) {
-  //  __android_log_print(ANDROID_LOG_ERROR, "projectM", "not freeing wave %x", *pos);
+
+  for (PresetOutputs::cwave_container::iterator pos = customWaves.begin();
+       pos != customWaves.end();
+       ++pos )
+  {
+    //  __android_log_print(ANDROID_LOG_ERROR, "projectM", "not freeing wave %x", *pos);
     delete(*pos);
   }
 
-  for (PresetOutputs::cshape_container::iterator pos = customShapes.begin(); 
-	pos != customShapes.end(); ++pos ) {
-//__android_log_print(ANDROID_LOG_ERROR, "projectM", "not freeing shape %x", *pos);
-
-	delete(*pos);
+  for (PresetOutputs::cshape_container::iterator pos = customShapes.begin();
+       pos != customShapes.end();
+       ++pos )
+  {
+    //__android_log_print(ANDROID_LOG_ERROR, "projectM", "not freeing shape %x", *pos);
+    delete(*pos);
   }
-  customWaves.clear();
- customShapes.clear();
- presetOutputs().customWaves.clear();
- presetOutputs().customShapes.clear();
-  presetOutputs().drawables.clear();
 
+  customWaves.clear();
+  customShapes.clear();
+  presetOutputs().customWaves.clear();
+  presetOutputs().customShapes.clear();
+  presetOutputs().drawables.clear();
 }
 
 /* Adds a per pixel equation according to its string name. This
    will be used only by the parser */
 
-int MilkdropPreset::add_per_pixel_eqn(char * name, GenExpr * gen_expr)
+int
+MilkdropPreset::add_per_pixel_eqn(char * name, GenExpr * gen_expr)
 {
-
   PerPixelEqn * per_pixel_eqn = NULL;
-  int index;
-  Param * param = NULL;
+  int         index;
+  Param       * param = NULL;
 
   assert(gen_expr);
   assert(name);
@@ -117,7 +117,7 @@
   if ( !param )
   {
     if (PER_PIXEL_EQN_DEBUG) printf("add_per_pixel_eqn: failed to allocate a new parameter!\n");
-    return PROJECTM_FAILURE;
+      return PROJECTM_FAILURE;
   }
 
   index = per_pixel_eqn_tree.size();
@@ -126,14 +126,14 @@
   if ((per_pixel_eqn = new PerPixelEqn(index, param, gen_expr)) == NULL)
   {
     if (PER_PIXEL_EQN_DEBUG) printf("add_per_pixel_eqn: failed to create new per pixel equation!\n");
-    return PROJECTM_FAILURE;
+      return PROJECTM_FAILURE;
   }
 
 
 
   /* Insert the per pixel equation into the preset per pixel database */
-  std::pair<std::map<int, PerPixelEqn*>::iterator, bool> inserteeOption = per_pixel_eqn_tree.insert
-      (std::make_pair(per_pixel_eqn->index, per_pixel_eqn));
+  std::pair<std::map<int, PerPixelEqn*>::iterator, bool> inserteeOption =
+      per_pixel_eqn_tree.insert (std::make_pair(per_pixel_eqn->index, per_pixel_eqn));
 
   if (!inserteeOption.second)
   {
@@ -146,99 +146,124 @@
   return PROJECTM_SUCCESS;
 }
 
-void MilkdropPreset::evalCustomShapeInitConditions()
+void
+MilkdropPreset::evalCustomShapeInitConditions()
 {
 
-  for (PresetOutputs::cshape_container::iterator pos = customShapes.begin(); pos != customShapes.end(); ++pos) {
+  for (PresetOutputs::cshape_container::iterator pos = customShapes.begin();
+       pos != customShapes.end();
+       ++pos)
+  {
     assert(*pos);
     (*pos)->evalInitConds();
   }
 }
 
 
-void MilkdropPreset::evalCustomWaveInitConditions()
+void
+MilkdropPreset::evalCustomWaveInitConditions()
 {
 
-  for (PresetOutputs::cwave_container::iterator pos = customWaves.begin(); pos != customWaves.end(); ++pos) {
+  for (PresetOutputs::cwave_container::iterator pos = customWaves.begin();
+       pos != customWaves.end();
+       ++pos)
+  {
     assert(*pos);
-   (*pos)->evalInitConds();
-}
+    (*pos)->evalInitConds();
+  }
 }
 
 
-void MilkdropPreset::evalCustomWavePerFrameEquations()
+void
+MilkdropPreset::evalCustomWavePerFrameEquations()
 {
 
-  for (PresetOutputs::cwave_container::iterator pos = customWaves.begin(); pos != customWaves.end(); ++pos)
+  for (PresetOutputs::cwave_container::iterator pos = customWaves.begin();
+       pos != customWaves.end();
+       ++pos)
   {
-
     std::map<std::string, InitCond*> & init_cond_tree = (*pos)->init_cond_tree;
-    for (std::map<std::string, InitCond*>::iterator _pos = init_cond_tree.begin(); _pos != init_cond_tree.end(); ++_pos)
+
+    for (std::map<std::string, InitCond*>::iterator _pos = init_cond_tree.begin();
+         _pos != init_cond_tree.end();
+         ++_pos)
     {
       assert(_pos->second);
       _pos->second->evaluate();
     }
 
     std::vector<PerFrameEqn*> & per_frame_eqn_tree = (*pos)->per_frame_eqn_tree;
-    for (std::vector<PerFrameEqn*>::iterator _pos = per_frame_eqn_tree.begin(); _pos != per_frame_eqn_tree.end(); ++_pos)
+    for (std::vector<PerFrameEqn*>::iterator _pos = per_frame_eqn_tree.begin();
+         _pos != per_frame_eqn_tree.end();
+         ++_pos)
     {
       (*_pos)->evaluate();
     }
   }
-
 }
 
-void MilkdropPreset::evalCustomShapePerFrameEquations()
+void
+MilkdropPreset::evalCustomShapePerFrameEquations()
 {
 
-  for (PresetOutputs::cshape_container::iterator pos = customShapes.begin(); pos != customShapes.end(); ++pos)
+  for (PresetOutputs::cshape_container::iterator pos = customShapes.begin();
+       pos != customShapes.end();
+       ++pos)
   {
-
     std::map<std::string, InitCond*> & init_cond_tree = (*pos)->init_cond_tree;
-    for (std::map<std::string, InitCond*>::iterator _pos = init_cond_tree.begin(); _pos != init_cond_tree.end(); ++_pos)
+
+    for (std::map<std::string, InitCond*>::iterator _pos = init_cond_tree.begin();
+         _pos != init_cond_tree.end();
+         ++_pos)
     {
       assert(_pos->second);
       _pos->second->evaluate();
     }
 
     std::vector<PerFrameEqn*> & per_frame_eqn_tree = (*pos)->per_frame_eqn_tree;
-    for (std::vector<PerFrameEqn*>::iterator _pos = per_frame_eqn_tree.begin(); _pos != per_frame_eqn_tree.end(); ++_pos)
+    for (std::vector<PerFrameEqn*>::iterator _pos = per_frame_eqn_tree.begin();
+         _pos != per_frame_eqn_tree.end();
+         ++_pos)
     {
       (*_pos)->evaluate();
     }
   }
-
 }
 
-void MilkdropPreset::evalPerFrameInitEquations()
+void
+MilkdropPreset::evalPerFrameInitEquations()
 {
+  for (std::map<std::string, InitCond*>::iterator pos = per_frame_init_eqn_tree.begin();
+       pos != per_frame_init_eqn_tree.end();
+       ++pos)
+  {
+    assert(pos->second);
+    pos->second->evaluate();
+  }
+}
 
-  for (std::map<std::string, InitCond*>::iterator pos = per_frame_init_eqn_tree.begin(); pos != per_frame_init_eqn_tree.end(); ++pos)
+void
+MilkdropPreset::evalPerFrameEquations()
+{
+  for (std::map<std::string, InitCond*>::iterator pos = init_cond_tree.begin();
+       pos != init_cond_tree.end();
+       ++pos)
   {
     assert(pos->second);
     pos->second->evaluate();
   }
 
-}
-
-void MilkdropPreset::evalPerFrameEquations()
-{
-
-  for (std::map<std::string, InitCond*>::iterator pos = init_cond_tree.begin(); pos != init_cond_tree.end(); ++pos)
-  {
-    assert(pos->second);
-    pos->second->evaluate();
-  }
-
-  for (std::vector<PerFrameEqn*>::iterator pos = per_frame_eqn_tree.begin(); pos != per_frame_eqn_tree.end(); ++pos)
+  for (std::vector<PerFrameEqn*>::iterator pos = per_frame_eqn_tree.begin();
+       pos != per_frame_eqn_tree.end();
+       ++pos)
   {
     (*pos)->evaluate();
   }
-
 }
 
-void MilkdropPreset::preloadInitialize() {
-
+void
+MilkdropPreset::preloadInitialize()
+{
   /// @note commented this out because it should be unnecessary
   // Clear equation trees
   //init_cond_tree.clear();
@@ -246,12 +271,11 @@
   //per_frame_eqn_tree.clear();
   //per_pixel_eqn_tree.clear();
   //per_frame_init_eqn_tree.clear();
-
-
 }
 
-void MilkdropPreset::postloadInitialize() {
-
+void
+MilkdropPreset::postloadInitialize()
+{
   /* It's kind of ugly to reset these values here. Should definitely be placed in the parser somewhere */
   this->per_frame_eqn_count = 0;
   this->per_frame_init_eqn_count = 0;
@@ -261,41 +285,42 @@
   this->loadCustomShapeUnspecInitConds();
 
 
-/// @bug are you handling all the q variables conditions? in particular, the un-init case?
-//m_presetOutputs.q1 = 0;
-//m_presetOutputs.q2 = 0;
-//m_presetOutputs.q3 = 0;
-//m_presetOutputs.q4 = 0;
-//m_presetOutputs.q5 = 0;
-//m_presetOutputs.q6 = 0;
-//m_presetOutputs.q7 = 0;
-//m_presetOutputs.q8 = 0;
-
+  /// @bug are you handling all the q variables conditions? in particular, the un-init case?
+  //m_presetOutputs.q1 = 0;
+  //m_presetOutputs.q2 = 0;
+  //m_presetOutputs.q3 = 0;
+  //m_presetOutputs.q4 = 0;
+  //m_presetOutputs.q5 = 0;
+  //m_presetOutputs.q6 = 0;
+  //m_presetOutputs.q7 = 0;
+  //m_presetOutputs.q8 = 0;
 }
 
-void MilkdropPreset::Render(const BeatDetect &music, const PipelineContext &context)
+void
+MilkdropPreset::Render(const BeatDetect &music, const PipelineContext &context)
 {
-	_presetInputs.update(music, context);
+  _presetInputs.update(music, context);
 
-	evaluateFrame();
-	pipeline().Render(music, context);
-
+  evaluateFrame();
+  pipeline().Render(music, context);
 }
 
-void MilkdropPreset::initialize(const std::string & pathname)
+void
+MilkdropPreset::initialize(const std::string & pathname)
 {
   int retval;
 
   preloadInitialize();
 
-if (MILKDROP_PRESET_DEBUG)
-  std::cerr << "[Preset] loading file \"" << pathname << "\"..." << std::endl;
+  if (MILKDROP_PRESET_DEBUG)
+    std::cerr << "[Preset] loading file \"" << pathname << "\"..." << std::endl;
 
   if ((retval = loadPresetFile(pathname)) < 0)
   {
-if (MILKDROP_PRESET_DEBUG)
-     std::cerr << "[Preset] failed to load file \"" <<
-      pathname << "\"!" << std::endl;
+    if (MILKDROP_PRESET_DEBUG)
+      std::cerr << "[Preset] failed to load file \""
+                << pathname << "\"!"
+                << std::endl;
 
     /// @bug how should we handle this problem? a well define exception?
     throw retval;
@@ -304,7 +329,8 @@
   postloadInitialize();
 }
 
-void MilkdropPreset::initialize(std::istream & in)
+void
+MilkdropPreset::initialize(std::istream & in)
 {
   int retval;
 
@@ -313,8 +339,8 @@
   if ((retval = readIn(in)) < 0)
   {
 
-	if (MILKDROP_PRESET_DEBUG)
-     std::cerr << "[Preset] failed to load from stream " << std::endl;
+    if (MILKDROP_PRESET_DEBUG)
+      std::cerr << "[Preset] failed to load from stream " << std::endl;
 
     /// @bug how should we handle this problem? a well define exception?
     throw retval;
@@ -323,7 +349,9 @@
   postloadInitialize();
 }
 
-void MilkdropPreset::loadBuiltinParamsUnspecInitConds() {
+void
+MilkdropPreset::loadBuiltinParamsUnspecInitConds()
+{
 
   InitCondUtils::LoadUnspecInitCond loadUnspecInitCond(this->init_cond_tree, this->per_frame_init_eqn_tree);
 
@@ -332,22 +360,24 @@
 
 }
 
-void MilkdropPreset::loadCustomWaveUnspecInitConds()
+void
+MilkdropPreset::loadCustomWaveUnspecInitConds()
 {
-
-  for (PresetOutputs::cwave_container::iterator pos = customWaves.begin(); pos != customWaves.end(); ++pos)
+  for (PresetOutputs::cwave_container::iterator pos = customWaves.begin();
+       pos != customWaves.end();
+       ++pos)
   {
     assert(*pos);
     (*pos)->loadUnspecInitConds();
   }
-
 }
 
-void MilkdropPreset::loadCustomShapeUnspecInitConds()
+void
+MilkdropPreset::loadCustomShapeUnspecInitConds()
 {
-
   for (PresetOutputs::cshape_container::iterator pos = customShapes.begin();
-	pos != customShapes.end(); ++pos)
+       pos != customShapes.end();
+       ++pos)
   {
     assert(*pos);
     (*pos)->loadUnspecInitConds();
@@ -355,9 +385,9 @@
 }
 
 
-void MilkdropPreset::evaluateFrame()
+void
+MilkdropPreset::evaluateFrame()
 {
-
   // Evaluate all equation objects according to milkdrop flow diagram
 
   evalPerFrameInitEquations();
@@ -382,110 +412,102 @@
   /// @slow an extra O(N) per frame, could do this during eval
   _presetOutputs.customWaves = PresetOutputs::cwave_container(customWaves);
   _presetOutputs.customShapes = PresetOutputs::cshape_container(customShapes);
-
 }
 
-void MilkdropPreset::initialize_PerPixelMeshes()
+void
+MilkdropPreset::initialize_PerPixelMeshes()
 {
-
   int x,y;
-      for (x=0;x<presetInputs().gx;x++){
-	for(y=0;y<presetInputs().gy;y++){
-	  _presetOutputs.cx_mesh[x][y]=presetOutputs().cx;
-	}}
 
+  for (x=0;x<presetInputs().gx;x++){
+    for(y=0;y<presetInputs().gy;y++){
+      _presetOutputs.cx_mesh[x][y]=presetOutputs().cx;
+    }
+  }
 
+  for (x=0;x<presetInputs().gx;x++){
+    for(y=0;y<presetInputs().gy;y++){
+      _presetOutputs.cy_mesh[x][y]=presetOutputs().cy;
+    }
+  }
 
+  for (x=0;x<presetInputs().gx;x++){
+    for(y=0;y<presetInputs().gy;y++){
+      _presetOutputs.sx_mesh[x][y]=presetOutputs().sx;
+    }
+  }
 
-      for (x=0;x<presetInputs().gx;x++){
-	for(y=0;y<presetInputs().gy;y++){
-	  _presetOutputs.cy_mesh[x][y]=presetOutputs().cy;
-	}}
+  for (x=0;x<presetInputs().gx;x++){
+    for(y=0;y<presetInputs().gy;y++){
+      _presetOutputs.sy_mesh[x][y]=presetOutputs().sy;
+    }
+  }
 
+  for (x=0;x<presetInputs().gx;x++){
+    for(y=0;y<presetInputs().gy;y++){
+      _presetOutputs.dx_mesh[x][y]=presetOutputs().dx;
+    }
+  }
 
+  //std::cout<<presetOutputs().cx<<","<<presetOutputs().cy<<" "<<presetOutputs().dx<<","<<presetOutputs().dy<<std::endl;
 
-      for (x=0;x<presetInputs().gx;x++){
-	for(y=0;y<presetInputs().gy;y++){
-	  _presetOutputs.sx_mesh[x][y]=presetOutputs().sx;
-	}}
+  for (x=0;x<presetInputs().gx;x++){
+    for(y=0;y<presetInputs().gy;y++){
+      _presetOutputs.dy_mesh[x][y]=presetOutputs().dy;
+    }
+  }
 
+  for (x=0;x<presetInputs().gx;x++){
+    for(y=0;y<presetInputs().gy;y++){
+      _presetOutputs.zoom_mesh[x][y]=presetOutputs().zoom;
+    }
+  }
 
+  for (x=0;x<presetInputs().gx;x++){
+    for(y=0;y<presetInputs().gy;y++){
+      _presetOutputs.zoomexp_mesh[x][y]=presetOutputs().zoomexp;
+    }
+  }
 
+  for (x=0;x<presetInputs().gx;x++){
+    for(y=0;y<presetInputs().gy;y++){
+      _presetOutputs.rot_mesh[x][y]=presetOutputs().rot;
+    }
+  }
 
-      for (x=0;x<presetInputs().gx;x++){
-	for(y=0;y<presetInputs().gy;y++){
-	  _presetOutputs.sy_mesh[x][y]=presetOutputs().sy;
-	}}
-
-
-
-      for (x=0;x<presetInputs().gx;x++){
-	for(y=0;y<presetInputs().gy;y++){
-	  _presetOutputs.dx_mesh[x][y]=presetOutputs().dx;
-	}}
-
-//std::cout<<presetOutputs().cx<<","<<presetOutputs().cy<<" "<<presetOutputs().dx<<","<<presetOutputs().dy<<std::endl;
-
-      for (x=0;x<presetInputs().gx;x++){
-	for(y=0;y<presetInputs().gy;y++){
-	  _presetOutputs.dy_mesh[x][y]=presetOutputs().dy;
-	}}
-
-
-
-      for (x=0;x<presetInputs().gx;x++){
-	for(y=0;y<presetInputs().gy;y++){
-	  _presetOutputs.zoom_mesh[x][y]=presetOutputs().zoom;
-	}}
-
-
-
-
-      for (x=0;x<presetInputs().gx;x++){
-	for(y=0;y<presetInputs().gy;y++){
-	  _presetOutputs.zoomexp_mesh[x][y]=presetOutputs().zoomexp;
-	}}
-
-
-
-      for (x=0;x<presetInputs().gx;x++){
-	for(y=0;y<presetInputs().gy;y++){
-	  _presetOutputs.rot_mesh[x][y]=presetOutputs().rot;
-	}}
-
-
-      for (x=0;x<presetInputs().gx;x++){
-	for(y=0;y<presetInputs().gy;y++){
-	  _presetOutputs.warp_mesh[x][y]=presetOutputs().warp;
-	}}
-
-
-
+  for (x=0;x<presetInputs().gx;x++){
+    for(y=0;y<presetInputs().gy;y++){
+      _presetOutputs.warp_mesh[x][y]=presetOutputs().warp;
+    }
+  }
 }
-// Evaluates all per-pixel equations
-void MilkdropPreset::evalPerPixelEqns()
-{
 
+// Evaluates all per-pixel equations
+void
+MilkdropPreset::evalPerPixelEqns()
+{
   /* Evaluate all per pixel equations in the tree datastructure */
   for (int mesh_x = 0; mesh_x < presetInputs().gx; mesh_x++)
-	  for (int mesh_y = 0; mesh_y < presetInputs().gy; mesh_y++)
-  for (std::map<int, PerPixelEqn*>::iterator pos = per_pixel_eqn_tree.begin();
-       pos != per_pixel_eqn_tree.end(); ++pos)
-    pos->second->evaluate(mesh_x, mesh_y);
-
+    for (int mesh_y = 0; mesh_y < presetInputs().gy; mesh_y++)
+      for (std::map<int, PerPixelEqn*>::iterator pos = per_pixel_eqn_tree.begin();
+           pos != per_pixel_eqn_tree.end();
+           ++pos)
+        pos->second->evaluate(mesh_x, mesh_y);
 }
 
-int MilkdropPreset::readIn(std::istream & fs) {
-
+int
+MilkdropPreset::readIn(std::istream & fs)
+{
   line_mode_t line_mode;
+
   presetOutputs().compositeShader.programSource.clear();
   presetOutputs().warpShader.programSource.clear();
 
   /* Parse any comments */
   if (Parser::parse_top_comment(fs) < 0)
   {
-	if (MILKDROP_PRESET_DEBUG)
-    		std::cerr << "[Preset::readIn] no left bracket found..." << std::endl;
+    if (MILKDROP_PRESET_DEBUG)
+      std::cerr << "[Preset::readIn] no left bracket found..." << std::endl;
     return PROJECTM_FAILURE;
   }
 
@@ -512,35 +534,34 @@
     }
   }
 
-//  std::cerr << "loadPresetFile: finished line parsing successfully" << std::endl;
+  //  std::cerr << "loadPresetFile: finished line parsing successfully" << std::endl;
 
   /* Now the preset has been loaded.
      Evaluation calls can be made at appropiate
      times in the frame loop */
 
-return PROJECTM_SUCCESS;
+  return PROJECTM_SUCCESS;
 }
 
 /* loadPresetFile: private function that loads a specific preset denoted
    by the given pathname */
-int MilkdropPreset::loadPresetFile(const std::string & pathname)
+int
+MilkdropPreset::loadPresetFile(const std::string & pathname)
 {
-
-
   /* Open the file corresponding to pathname */
   std::ifstream fs(pathname.c_str());
+
   if (!fs || fs.eof()) {
     if (MILKDROP_PRESET_DEBUG)
-    	std::cerr << "loadPresetFile: loading of file \"" << pathname << "\" failed!\n";
+      std::cerr << "loadPresetFile: loading of file \"" << pathname << "\" failed!\n";
     return PROJECTM_ERROR;
   }
 
- return readIn(fs);
-
+  return readIn(fs);
 }
 
-const std::string & MilkdropPreset::name() const {
-	
-	return name().empty() ? filename() : name();
+const std::string &
+MilkdropPreset::name() const
+{
+  return name().empty() ? filename() : name();
 }
-
diff --git a/src/libprojectM/MilkdropPresetFactory/MilkdropPreset.hpp b/src/libprojectM/MilkdropPresetFactory/MilkdropPreset.hpp
index 89fc7f8..ddfbd52 100644
--- a/src/libprojectM/MilkdropPresetFactory/MilkdropPreset.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/MilkdropPreset.hpp
@@ -1,4 +1,3 @@
-
 /**
  * projectM -- Milkdrop-esque visualisation SDK
  * Copyright (C)2003-2007 projectM Team
@@ -26,7 +25,6 @@
  *
  * $Log$
  */
-
 #ifndef _MilkdropPreset_HPP
 #define _MilkdropPreset_HPP
 
@@ -47,6 +45,7 @@
 #include "InitCond.hpp"
 #include "Preset.hpp"
 
+
 class CustomWave;
 class CustomShape;
 class InitCond;
@@ -109,18 +108,16 @@
   /// \returns A MilkdropPreset output instance with values computed from most recent evaluateFrame()
   PresetOutputs & presetOutputs() const
   {
-
     return _presetOutputs;
   }
 
   const PresetInputs & presetInputs() const
   {
-
     return _presetInputs;
   }
 
 
-// @bug encapsulate
+  // @bug encapsulate
 
   PresetOutputs::cwave_container customWaves;
   PresetOutputs::cshape_container customShapes;
@@ -134,13 +131,13 @@
   std::map<std::string,Param*> user_param_tree; /* user parameter splay tree */
 
 
-  PresetOutputs & pipeline() { return _presetOutputs; } 
+  PresetOutputs & pipeline() { return _presetOutputs; }
 
   void Render(const BeatDetect &music, const PipelineContext &context);
   const std::string & name() const;
-  const std::string & filename() const { return _filename; } 
-private:
-  std::string _filename; 
+  const std::string & filename() const { return _filename; }
+  private:
+  std::string _filename;
   PresetInputs _presetInputs;
   /// Evaluates the MilkdropPreset for a frame given the current values of MilkdropPreset inputs / outputs
   /// All calculated values are stored in the associated MilkdropPreset outputs instance
@@ -173,53 +170,52 @@
 
   void preloadInitialize();
   void postloadInitialize();
-  
+
   PresetOutputs & _presetOutputs;
 
-template <class CustomObject>
-void transfer_q_variables(std::vector<CustomObject*> & customObjects);
+  template <class CustomObject>
+  void transfer_q_variables(std::vector<CustomObject*> & customObjects);
 };
 
 
-template <class CustomObject>
-void MilkdropPreset::transfer_q_variables(std::vector<CustomObject*> & customObjects)
+template <class CustomObject> void
+MilkdropPreset::transfer_q_variables(std::vector<CustomObject*> & customObjects)
 {
- 	CustomObject * custom_object;
+  CustomObject * custom_object;
 
-	for (typename std::vector<CustomObject*>::iterator pos = customObjects.begin(); pos != customObjects.end();++pos) {
-
-		custom_object = *pos;
-		for (unsigned int i = 0; i < NUM_Q_VARIABLES; i++)
-			custom_object->q[i] = _presetOutputs.q[i];
-	}
-
-
+  for (typename std::vector<CustomObject*>::iterator pos = customObjects.begin();
+       pos != customObjects.end();
+       ++pos)
+  {
+    custom_object = *pos;
+    for (unsigned int i = 0; i < NUM_Q_VARIABLES; i++)
+      custom_object->q[i] = _presetOutputs.q[i];
+  }
 }
 
-template <class CustomObject>
-CustomObject * MilkdropPreset::find_custom_object(int id, std::vector<CustomObject*> & customObjects)
+template <class CustomObject> CustomObject *
+MilkdropPreset::find_custom_object(int id, std::vector<CustomObject*> & customObjects)
 {
-
   CustomObject * custom_object = NULL;
 
-
-  for (typename std::vector<CustomObject*>::iterator pos = customObjects.begin(); pos != customObjects.end();++pos) {
-	if ((*pos)->id == id) {
-		custom_object = *pos;
-		break;
-	}
+  for (typename std::vector<CustomObject*>::iterator pos = customObjects.begin();
+       pos != customObjects.end();
+       ++pos)
+  {
+    if ((*pos)->id == id) {
+      custom_object = *pos;
+      break;
+    }
   }
 
   if (custom_object == NULL)
   {
-
     if ((custom_object = new CustomObject(id)) == NULL)
     {
       return NULL;
     }
 
-      customObjects.push_back(custom_object);
-
+    customObjects.push_back(custom_object);
   }
 
   assert(custom_object);
@@ -227,5 +223,4 @@
 }
 
 
-
 #endif /** !_MilkdropPreset_HPP */
diff --git a/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.cpp b/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.cpp
index 0418a7c..3bcd620 100644
--- a/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.cpp
@@ -17,211 +17,217 @@
 #include "IdlePreset.hpp"
 #include "PresetFrameIO.hpp"
 
-MilkdropPresetFactory::MilkdropPresetFactory(int gx, int gy): _usePresetOutputs(false)
+
+MilkdropPresetFactory::MilkdropPresetFactory(int gx, int gy)
+  : _usePresetOutputs(false)
 {
-	/* Initializes the builtin function database */
-	BuiltinFuncs::init_builtin_func_db();
+  /* Initializes the builtin function database */
+  BuiltinFuncs::init_builtin_func_db();
 
-	/* Initializes all infix operators */
-	Eval::init_infix_ops();
+  /* Initializes all infix operators */
+  Eval::init_infix_ops();
 
-	_presetOutputs = createPresetOutputs(gx,gy);
-	_presetOutputs2 = createPresetOutputs(gx, gy);
+  _presetOutputs = createPresetOutputs(gx,gy);
+  _presetOutputs2 = createPresetOutputs(gx, gy);
 }
 
-MilkdropPresetFactory::~MilkdropPresetFactory() {
-
-	std::cerr << "[~MilkdropPresetFactory] destroy infix ops" << std::endl;
-	Eval::destroy_infix_ops();
-	std::cerr << "[~MilkdropPresetFactory] destroy builtin func" << std::endl;
-	BuiltinFuncs::destroy_builtin_func_db();
-	std::cerr << "[~MilkdropPresetFactory] delete preset out puts" << std::endl;
-	delete(_presetOutputs);
-        delete(_presetOutputs2);
-	std::cerr << "[~MilkdropPresetFactory] done" << std::endl;
-
+MilkdropPresetFactory::~MilkdropPresetFactory()
+{
+  std::cerr << "[~MilkdropPresetFactory] destroy infix ops" << std::endl;
+  Eval::destroy_infix_ops();
+  std::cerr << "[~MilkdropPresetFactory] destroy builtin func" << std::endl;
+  BuiltinFuncs::destroy_builtin_func_db();
+  std::cerr << "[~MilkdropPresetFactory] delete preset out puts" << std::endl;
+  delete(_presetOutputs);
+  delete(_presetOutputs2);
+  std::cerr << "[~MilkdropPresetFactory] done" << std::endl;
 }
 
 /* Reinitializes the engine variables to a default (conservative and sane) value */
-void resetPresetOutputs(PresetOutputs * presetOutputs)
+void
+resetPresetOutputs(PresetOutputs * presetOutputs)
 {
+  presetOutputs->zoom               = 1.0;
+  presetOutputs->zoomexp            = 1.0;
+  presetOutputs->rot                = 0.0;
+  presetOutputs->warp               = 0.0;
 
-    presetOutputs->zoom=1.0;
-    presetOutputs->zoomexp = 1.0;
-    presetOutputs->rot= 0.0;
-    presetOutputs->warp= 0.0;
+  presetOutputs->sx                 = 1.0;
+  presetOutputs->sy                 = 1.0;
+  presetOutputs->dx                 = 0.0;
+  presetOutputs->dy                 = 0.0;
+  presetOutputs->cx                 = 0.5;
+  presetOutputs->cy                 = 0.5;
 
-    presetOutputs->sx= 1.0;
-    presetOutputs->sy= 1.0;
-    presetOutputs->dx= 0.0;
-    presetOutputs->dy= 0.0;
-    presetOutputs->cx= 0.5;
-    presetOutputs->cy= 0.5;
+  presetOutputs->screenDecay        = .98;
 
-    presetOutputs->screenDecay=.98;
+  presetOutputs->wave.r             = 1.0;
+  presetOutputs->wave.g             = 0.2;
+  presetOutputs->wave.b             = 0.0;
+  presetOutputs->wave.x             = 0.5;
+  presetOutputs->wave.y             = 0.5;
+  presetOutputs->wave.mystery       = 0.0;
 
-    presetOutputs->wave.r= 1.0;
-    presetOutputs->wave.g= 0.2;
-    presetOutputs->wave.b= 0.0;
-    presetOutputs->wave.x= 0.5;
-    presetOutputs->wave.y= 0.5;
-    presetOutputs->wave.mystery= 0.0;
+  presetOutputs->border.outer_size  = 0.0;
+  presetOutputs->border.outer_r     = 0.0;
+  presetOutputs->border.outer_g     = 0.0;
+  presetOutputs->border.outer_b     = 0.0;
+  presetOutputs->border.outer_a     = 0.0;
 
-    presetOutputs->border.outer_size= 0.0;
-    presetOutputs->border.outer_r= 0.0;
-    presetOutputs->border.outer_g= 0.0;
-    presetOutputs->border.outer_b= 0.0;
-    presetOutputs->border.outer_a= 0.0;
+  presetOutputs->border.inner_size  = 0.0;
+  presetOutputs->border.inner_r     = 0.0;
+  presetOutputs->border.inner_g     = 0.0;
+  presetOutputs->border.inner_b     = 0.0;
+  presetOutputs->border.inner_a     = 0.0;
 
-    presetOutputs->border.inner_size = 0.0;
-    presetOutputs->border.inner_r = 0.0;
-    presetOutputs->border.inner_g = 0.0;
-    presetOutputs->border.inner_b = 0.0;
-    presetOutputs->border.inner_a = 0.0;
-
-    presetOutputs->mv.a = 0.0;
-    presetOutputs->mv.r = 0.0;
-    presetOutputs->mv.g = 0.0;
-    presetOutputs->mv.b = 0.0;
-    presetOutputs->mv.length = 1.0;
-    presetOutputs->mv.x_num = 16.0;
-    presetOutputs->mv.y_num = 12.0;
-    presetOutputs->mv.x_offset = 0.02;
-    presetOutputs->mv.y_offset = 0.02;
+  presetOutputs->mv.a               = 0.0;
+  presetOutputs->mv.r               = 0.0;
+  presetOutputs->mv.g               = 0.0;
+  presetOutputs->mv.b               = 0.0;
+  presetOutputs->mv.length          = 1.0;
+  presetOutputs->mv.x_num           = 16.0;
+  presetOutputs->mv.y_num           = 12.0;
+  presetOutputs->mv.x_offset        = 0.02;
+  presetOutputs->mv.y_offset        = 0.02;
 
 
-    /* PER_FRAME CONSTANTS END */
-    presetOutputs->fRating = 0;
-    presetOutputs->fGammaAdj = 1.0;
-    presetOutputs->videoEcho.zoom = 1.0;
-    presetOutputs->videoEcho.a = 0;
-    presetOutputs->videoEcho.orientation = Normal;
+  /* PER_FRAME CONSTANTS END */
+  presetOutputs->fRating            = 0;
+  presetOutputs->fGammaAdj          = 1.0;
+  presetOutputs->videoEcho.zoom         = 1.0;
+  presetOutputs->videoEcho.a            = 0;
+  presetOutputs->videoEcho.orientation  = Normal;
 
-    presetOutputs->wave.additive = false;
-    presetOutputs->wave.dots = false;
-    presetOutputs->wave.thick = false;
-    presetOutputs->wave.modulateAlphaByVolume = 0;
-    presetOutputs->wave.maximizeColors = 0;
-    presetOutputs->textureWrap = 0;
-    presetOutputs->bDarkenCenter = 0;
-    presetOutputs->bRedBlueStereo = 0;
-    presetOutputs->bBrighten = 0;
-    presetOutputs->bDarken = 0;
-    presetOutputs->bSolarize = 0;
-    presetOutputs->bInvert = 0;
-    presetOutputs->bMotionVectorsOn = 1;
+  presetOutputs->wave.additive              = false;
+  presetOutputs->wave.dots                  = false;
+  presetOutputs->wave.thick                 = false;
+  presetOutputs->wave.modulateAlphaByVolume = 0;
+  presetOutputs->wave.maximizeColors        = 0;
+  presetOutputs->textureWrap        = 0;
+  presetOutputs->bDarkenCenter      = 0;
+  presetOutputs->bRedBlueStereo     = 0;
+  presetOutputs->bBrighten          = 0;
+  presetOutputs->bDarken            = 0;
+  presetOutputs->bSolarize          = 0;
+  presetOutputs->bInvert            = 0;
+  presetOutputs->bMotionVectorsOn   = 1;
 
-    presetOutputs->wave.a =1.0;
-    presetOutputs->wave.scale = 1.0;
-    presetOutputs->wave.smoothing = 0;
-    presetOutputs->wave.mystery = 0;
-    presetOutputs->wave.modOpacityEnd = 0;
-    presetOutputs->wave.modOpacityStart = 0;
-    presetOutputs->fWarpAnimSpeed = 0;
-    presetOutputs->fWarpScale = 0;
-    presetOutputs->fShader = 0;
+  presetOutputs->wave.a               =1.0;
+  presetOutputs->wave.scale           = 1.0;
+  presetOutputs->wave.smoothing       = 0;
+  presetOutputs->wave.mystery         = 0;
+  presetOutputs->wave.modOpacityEnd   = 0;
+  presetOutputs->wave.modOpacityStart = 0;
+  presetOutputs->fWarpAnimSpeed     = 0;
+  presetOutputs->fWarpScale         = 0;
+  presetOutputs->fShader            = 0;
 
-    /* PER_PIXEL CONSTANT END */
-    /* Q VARIABLES START */
+  /* PER_PIXEL CONSTANT END */
+  /* Q VARIABLES START */
 
-    for (int i = 0;i< 32;i++)
-        presetOutputs->q[i] = 0;
+  for (int i = 0;i< 32;i++)
+    presetOutputs->q[i] = 0;
 
-//	for ( std::vector<CustomWave*>::iterator pos = presetOutputs->customWaves.begin();
-//	        pos != presetOutputs->customWaves.end(); ++pos )
-//		if ( *pos != 0 ) delete ( *pos );
-	
-//	for ( std::vector<CustomShape*>::iterator pos = presetOutputs->customShapes.begin();
-//	        pos != presetOutputs->customShapes.end(); ++pos )
-//		if ( *pos != 0 ) delete ( *pos );
-	
-	presetOutputs->customWaves.clear();
-	presetOutputs->customShapes.clear();
+  //  for ( std::vector<CustomWave*>::iterator pos = presetOutputs->customWaves.begin();
+  //          pos != presetOutputs->customWaves.end(); ++pos )
+  //    if ( *pos != 0 ) delete ( *pos );
 
-    /* Q VARIABLES END */
+  //  for ( std::vector<CustomShape*>::iterator pos = presetOutputs->customShapes.begin();
+  //          pos != presetOutputs->customShapes.end(); ++pos )
+  //    if ( *pos != 0 ) delete ( *pos );
 
+  presetOutputs->customWaves.clear();
+  presetOutputs->customShapes.clear();
+
+  /* Q VARIABLES END */
 }
 
 
 /* Reinitializes the engine variables to a default (conservative and sane) value */
-void MilkdropPresetFactory::reset()
+void
+MilkdropPresetFactory::reset()
 {
-
-    resetPresetOutputs(_presetOutputs);
-    resetPresetOutputs(_presetOutputs2);
+  resetPresetOutputs(_presetOutputs);
+  resetPresetOutputs(_presetOutputs2);
 }
 
-PresetOutputs* MilkdropPresetFactory::createPresetOutputs(int gx, int gy)
+PresetOutputs*
+MilkdropPresetFactory::createPresetOutputs(int gx, int gy)
 {
+  PresetOutputs *presetOutputs = new PresetOutputs();
 
-	PresetOutputs *presetOutputs = new PresetOutputs();
+  presetOutputs->Initialize(gx,gy);
 
-	presetOutputs->Initialize(gx,gy);
+  /* PER FRAME CONSTANTS BEGIN */
+  presetOutputs->zoom               = 1.0;
+  presetOutputs->zoomexp            = 1.0;
+  presetOutputs->rot                = 0.0;
+  presetOutputs->warp               = 0.0;
 
-	/* PER FRAME CONSTANTS BEGIN */
-	presetOutputs->zoom=1.0;
-	presetOutputs->zoomexp = 1.0;
-	presetOutputs->rot= 0.0;
-	presetOutputs->warp= 0.0;
+  presetOutputs->sx                 = 1.0;
+  presetOutputs->sy                 = 1.0;
+  presetOutputs->dx                 = 0.0;
+  presetOutputs->dy                 = 0.0;
+  presetOutputs->cx                 = 0.5;
+  presetOutputs->cy                 = 0.5;
 
-	presetOutputs->sx= 1.0;
-	presetOutputs->sy= 1.0;
-	presetOutputs->dx= 0.0;
-	presetOutputs->dy= 0.0;
-	presetOutputs->cx= 0.5;
-	presetOutputs->cy= 0.5;
-
-	presetOutputs->screenDecay=.98;
+  presetOutputs->screenDecay        =.98;
 
 
-//_presetInputs.meshx = 0;
-//_presetInputs.meshy = 0;
+  //_presetInputs.meshx = 0;
+  //_presetInputs.meshy = 0;
 
 
-	/* PER_FRAME CONSTANTS END */
-	presetOutputs->fRating = 0;
-	presetOutputs->fGammaAdj = 1.0;
-	presetOutputs->videoEcho.zoom = 1.0;
-	presetOutputs->videoEcho.a = 0;
-	presetOutputs->videoEcho.orientation = Normal;
+  /* PER_FRAME CONSTANTS END */
+  presetOutputs->fRating            = 0;
+  presetOutputs->fGammaAdj          = 1.0;
+  presetOutputs->videoEcho.zoom         = 1.0;
+  presetOutputs->videoEcho.a            = 0;
+  presetOutputs->videoEcho.orientation  = Normal;
 
-	presetOutputs->textureWrap = 0;
-	presetOutputs->bDarkenCenter = 0;
-	presetOutputs->bRedBlueStereo = 0;
-	presetOutputs->bBrighten = 0;
-	presetOutputs->bDarken = 0;
-	presetOutputs->bSolarize = 0;
-	presetOutputs->bInvert = 0;
-	presetOutputs->bMotionVectorsOn = 1;
+  presetOutputs->textureWrap        = 0;
+  presetOutputs->bDarkenCenter      = 0;
+  presetOutputs->bRedBlueStereo     = 0;
+  presetOutputs->bBrighten          = 0;
+  presetOutputs->bDarken            = 0;
+  presetOutputs->bSolarize          = 0;
+  presetOutputs->bInvert            = 0;
+  presetOutputs->bMotionVectorsOn   = 1;
 
-    	presetOutputs->fWarpAnimSpeed = 0;
-	presetOutputs->fWarpScale = 0;
-	presetOutputs->fShader = 0;
+  presetOutputs->fWarpAnimSpeed     = 0;
+  presetOutputs->fWarpScale         = 0;
+  presetOutputs->fShader            = 0;
 
-	/* PER_PIXEL CONSTANTS BEGIN */
+  /* PER_PIXEL CONSTANTS BEGIN */
 
-	/* PER_PIXEL CONSTANT END */
+  /* PER_PIXEL CONSTANT END */
 
-	/* Q AND T VARIABLES START */
+  /* Q AND T VARIABLES START */
 
-	for (int i = 0;i<NUM_Q_VARIABLES;i++)
-		presetOutputs->q[i] = 0;
-	
-	/* Q AND T VARIABLES END */
-    return presetOutputs;
+  for (int i = 0;  i < NUM_Q_VARIABLES;  i++)
+    presetOutputs->q[i] = 0;
+
+  /* Q AND T VARIABLES END */
+  return presetOutputs;
 }
 
 
-std::auto_ptr<Preset> MilkdropPresetFactory::allocate(const std::string & url, const std::string & name, const std::string & author) {
+std::auto_ptr<Preset>
+MilkdropPresetFactory::allocate(
+const std::string & url,
+const std::string & name,
+const std::string & author
+)
+{
+  PresetOutputs *presetOutputs = _usePresetOutputs ? _presetOutputs : _presetOutputs2;
 
-    PresetOutputs *presetOutputs = _usePresetOutputs ? _presetOutputs : _presetOutputs2;
+  _usePresetOutputs = !_usePresetOutputs;
+  resetPresetOutputs(presetOutputs);
 
-	_usePresetOutputs = !_usePresetOutputs;
-	resetPresetOutputs(presetOutputs);
+  std::string path;
 
-	std::string path;
-	if (PresetFactory::protocol(url, path) == PresetFactory::IDLE_PRESET_PROTOCOL) {
-		return IdlePresets::allocate(path, *presetOutputs);
-	} else
-		return std::auto_ptr<Preset>(new MilkdropPreset(url, name, *presetOutputs));
+  if (PresetFactory::protocol(url, path) == PresetFactory::IDLE_PRESET_PROTOCOL) {
+    return IdlePresets::allocate(path, *presetOutputs);
+  } else
+    return std::auto_ptr<Preset>(new MilkdropPreset(url, name, *presetOutputs));
 }
diff --git a/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.hpp b/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.hpp
index 2a5a46a..4dff790 100644
--- a/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/MilkdropPresetFactory.hpp
@@ -9,35 +9,37 @@
 // Copyright: See COPYING file that comes with this distribution
 //
 //
-
 #ifndef __MILKDROP_PRESET_FACTORY_HPP
 #define __MILKDROP_PRESET_FACTORY_HPP
 
 #include <memory>
 #include "../PresetFactory.hpp"
+
+
 class DLLEXPORT PresetOutputs;
 class DLLEXPORT PresetInputs;
 
+
 class MilkdropPresetFactory : public PresetFactory {
 
 public:
 
- MilkdropPresetFactory(int gx, int gy);
+  MilkdropPresetFactory(int gx, int gy);
 
- virtual ~MilkdropPresetFactory();
+  virtual ~MilkdropPresetFactory();
 
- std::auto_ptr<Preset> allocate(const std::string & url, const std::string & name = std::string(),
-	const std::string & author = std::string());
+  std::auto_ptr<Preset> allocate(const std::string & url, const std::string & name = std::string(),
+                                 const std::string & author = std::string());
 
- std::string supportedExtensions() const { return "milk prjm"; }
+  std::string supportedExtensions() const { return "milk prjm"; }
 
 private:
-    static PresetOutputs* createPresetOutputs(int gx, int gy);
-	void reset();
-	PresetOutputs * _presetOutputs;
-    PresetOutputs * _presetOutputs2;
-    bool _usePresetOutputs;
-	//PresetInputs _presetInputs;
+  static PresetOutputs* createPresetOutputs(int gx, int gy);
+  void reset();
+  PresetOutputs * _presetOutputs;
+  PresetOutputs * _presetOutputs2;
+  bool _usePresetOutputs;
+  //PresetInputs _presetInputs;
 };
 
 #endif
diff --git a/src/libprojectM/MilkdropPresetFactory/Param.cpp b/src/libprojectM/MilkdropPresetFactory/Param.cpp
index ca21e8f..ebc854f 100644
--- a/src/libprojectM/MilkdropPresetFactory/Param.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/Param.cpp
@@ -39,161 +39,181 @@
 #include <iostream>
 #include <cassert>
 
+
 /** Constructor */
 Param::Param( std::string _name, short int _type, short int _flags, void * _engine_val, void * _matrix,
-              CValue _default_init_val, CValue _upper_bound, CValue _lower_bound):
-	name(_name),
-        type(_type),
-        flags (_flags),
-        matrix_flag (0),
-        engine_val(_engine_val),
-        matrix (_matrix),
-        default_init_val (_default_init_val),
-        upper_bound (_upper_bound),
-        lower_bound (_lower_bound)
-    {
+              CValue _default_init_val, CValue _upper_bound, CValue _lower_bound)
+  : name(_name),
+    type(_type),
+    flags (_flags),
+    matrix_flag (0),
+    engine_val(_engine_val),
+    matrix (_matrix),
+    default_init_val (_default_init_val),
+    upper_bound (_upper_bound),
+    lower_bound (_lower_bound)
+{
 
 }
 
 
 /* Creates a user defined parameter */
-Param::Param(std::string _name) :
-	name(_name),
-        type(P_TYPE_DOUBLE),
-	flags(P_FLAG_USERDEF),
-        matrix_flag(0),
-        matrix(0)
-        {
+Param::Param(std::string _name)
+  : name(_name),
+    type(P_TYPE_DOUBLE),
+    flags(P_FLAG_USERDEF),
+    matrix_flag(0),
+    matrix(0)
+{
+  engine_val = new float();
 
-	engine_val = new float();
+  default_init_val.float_val = DEFAULT_DOUBLE_IV;
+  upper_bound.float_val = DEFAULT_DOUBLE_UB;
+  lower_bound.float_val = DEFAULT_DOUBLE_LB;
 
-	default_init_val.float_val = DEFAULT_DOUBLE_IV;
-        upper_bound.float_val = DEFAULT_DOUBLE_UB;
-        lower_bound.float_val = DEFAULT_DOUBLE_LB;
-
-    /// @note may have fixed a recent bug. testing
-    *((float*)engine_val) = default_init_val.float_val;
-
-   
+  /// @note may have fixed a recent bug. testing
+  *((float*)engine_val) = default_init_val.float_val;
 }
 
 /* Free's a parameter type */
-Param::~Param() {
+Param::~Param()
+{
+  // I hate this, but will let it be for now
+  if (flags & P_FLAG_USERDEF) {
+    delete((double*)engine_val);
+  }
 
-    // I hate this, but will let it be for now
-    if (flags & P_FLAG_USERDEF) {
-        delete((double*)engine_val);
-    }
-
-    if (PARAM_DEBUG) printf("~Param: freeing \"%s\".\n", name.c_str());
+  if (PARAM_DEBUG) printf("~Param: freeing \"%s\".\n", name.c_str());
 }
 
 
 /* Returns nonzero if the string is valid parameter name */
-bool Param::is_valid_param_string( const char * string ) {
+bool
+Param::is_valid_param_string( const char * string )
+{
 
-    if (string == NULL)
-        return false;
+  if (string == NULL)
+    return false;
 
-    /* This ensures the first character is non numeric */
-    if ( ((*string) >= 48) && ((*string) <= 57))
-        return false;
+  /* This ensures the first character is non numeric */
+  if ( ((*string) >= 48) && ((*string) <= 57))
+    return false;
 
-    /* These probably should never happen */
-    if (*string == '.')
-        return false;
+  /* These probably should never happen */
+  if (*string == '.')
+    return false;
 
-    if (*string == '+')
-        return false;
+  if (*string == '+')
+    return false;
 
-    if (*string == '-')
-        return false;
+  if (*string == '-')
+    return false;
 
-    /* Could also add checks for other symbols. May do later */
+  /* Could also add checks for other symbols. May do later */
 
-    return true;
-
+  return true;
 }
 
 
 
 /* Loads a float parameter into the builtin database */
-Param * Param::new_param_float(const char * name, short int flags, void * engine_val, void * matrix,
-                               float upper_bound, float lower_bound, float init_val) {
+Param *
+Param::new_param_float (
+const char  * name,
+short int   flags,
+void        * engine_val,
+void        * matrix,
+float       upper_bound,
+float       lower_bound,
+float       init_val
+)
+{
+  Param   * param;
+  CValue  iv, ub, lb;
+  assert(engine_val);
 
-    Param * param;
-    CValue iv, ub, lb;
-    assert(engine_val);
+  iv.float_val = init_val;
+  ub.float_val = upper_bound;
+  lb.float_val = lower_bound;
 
-    iv.float_val = init_val;
-    ub.float_val = upper_bound;
-    lb.float_val = lower_bound;
-
-    if ((param = new Param(name, P_TYPE_DOUBLE, flags, engine_val, matrix,iv, ub, lb)) == NULL)
-        return NULL;
+  if ((param = new Param(name, P_TYPE_DOUBLE, flags, engine_val, matrix,iv, ub, lb)) == NULL)
+    return NULL;
 
 
-    /* Finished, return success */
-    return param;
+  /* Finished, return success */
+  return param;
 }
 
 /* Creates a new parameter of type int */
-Param * Param::new_param_int(const char * name, short int flags, void * engine_val,	
-                             int upper_bound, int lower_bound, int init_val) {
+Param *
+Param::new_param_int (
+const char  * name,
+short int   flags,
+void        * engine_val,
+int         upper_bound,
+int         lower_bound,
+int         init_val
+)
+{
+  Param   * param;
+  CValue  iv, ub, lb;
+  assert(engine_val);
 
-    Param * param;
-    CValue iv, ub, lb;
-    assert(engine_val);
+  iv.int_val = init_val;
+  ub.int_val = upper_bound;
+  lb.int_val = lower_bound;
 
-    iv.int_val = init_val;
-    ub.int_val = upper_bound;
-    lb.int_val = lower_bound;
-
-    if ((param = new Param(name, P_TYPE_INT, flags, engine_val, NULL, iv, ub, lb)) == NULL)
-        return NULL;
+  if ((param = new Param(name, P_TYPE_INT, flags, engine_val, NULL, iv, ub, lb)) == NULL)
+    return NULL;
 
 
-    /* Finished, return success */
-    return param;
+  /* Finished, return success */
+  return param;
 }
 
 /* Creates a new parameter of type bool */
-Param * Param::new_param_bool(const char * name, short int flags, void * engine_val,
-                              bool upper_bound, bool lower_bound, bool init_val) {
+Param *
+Param::new_param_bool (
+const char  * name,
+short int   flags,
+void        * engine_val,
+bool        upper_bound,
+bool        lower_bound,
+bool        init_val
+)
+{
+  Param   * param;
+  CValue  iv, ub, lb;
+  assert(engine_val);
 
-    Param * param;
-    CValue iv, ub, lb;
-    assert(engine_val);
+  iv.bool_val = init_val;
+  ub.bool_val = upper_bound;
+  lb.bool_val = lower_bound;
 
-    iv.bool_val = init_val;
-    ub.bool_val = upper_bound;
-    lb.bool_val = lower_bound;
-
-    if ((param = new Param(name, P_TYPE_BOOL, flags, engine_val, NULL, iv, ub, lb)) == NULL)
-        return NULL;
+  if ((param = new Param(name, P_TYPE_BOOL, flags, engine_val, NULL, iv, ub, lb)) == NULL)
+    return NULL;
 
 
-    /* Finished, return success */
-    return param;
+  /* Finished, return success */
+  return param;
 }
 
 /* Creates a new parameter of type string */
-Param * Param::new_param_string(const char * name, short int flags, void * engine_val) {
+Param *
+Param::new_param_string (const char * name, short int flags, void * engine_val)
+{
+  Param   * param;
+  CValue  iv, ub, lb;
+  assert(engine_val);
 
-    Param * param;
-    CValue iv, ub, lb;
-    assert(engine_val);
+  iv.bool_val = 0;
+  ub.bool_val = 0;
+  lb.bool_val = 0;
 
-    iv.bool_val = 0;
-    ub.bool_val = 0;
-    lb.bool_val = 0;
-
-    if ((param = new Param(name, P_TYPE_STRING, flags, engine_val, NULL, iv, ub, lb)) == NULL)
-        return NULL;
+  if ((param = new Param(name, P_TYPE_STRING, flags, engine_val, NULL, iv, ub, lb)) == NULL)
+    return NULL;
 
 
-    /* Finished, return success */
-    return param;
+  /* Finished, return success */
+  return param;
 }
-
-
diff --git a/src/libprojectM/MilkdropPresetFactory/Param.hpp b/src/libprojectM/MilkdropPresetFactory/Param.hpp
index 1f6bcf2..c422819 100644
--- a/src/libprojectM/MilkdropPresetFactory/Param.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/Param.hpp
@@ -25,7 +25,6 @@
  *
  * $Log$
  */
-
 #ifndef _PARAM_H
 #define _PARAM_H
 
@@ -54,6 +53,8 @@
 #include "Common.hpp"
 #include <cmath>
 #include <string>
+
+
 class InitCond;
 class Param;
 class Preset;
@@ -62,90 +63,88 @@
 /* Parameter Type */
 class Param {
 public:
-    std::string name; /* name of the parameter, not necessary but useful neverthless */
-    short int type; /* parameter number type (int, bool, or float) */
-    short int flags; /* read, write, user defined, etc */
-    short int matrix_flag; /* for optimization purposes */
-    void * engine_val; /* pointer to the engine variable */
-    void * matrix; /* per pixel / per point matrix for this variable */
-    CValue default_init_val; /* a default initial condition value */
-    CValue upper_bound; /* this parameter's upper bound */
-    CValue lower_bound; /* this parameter's lower bound */
+  std::string name; /* name of the parameter, not necessary but useful neverthless */
+  short int type; /* parameter number type (int, bool, or float) */
+  short int flags; /* read, write, user defined, etc */
+  short int matrix_flag; /* for optimization purposes */
+  void * engine_val; /* pointer to the engine variable */
+  void * matrix; /* per pixel / per point matrix for this variable */
+  CValue default_init_val; /* a default initial condition value */
+  CValue upper_bound; /* this parameter's upper bound */
+  CValue lower_bound; /* this parameter's lower bound */
 
-    /// Create a new parameter
-    Param(std::string name, short int type, short int flags,
-           void * eqn_val, void *matrix,
-           CValue default_init_val, CValue upper_bound,
-           CValue lower_bound);
+  /// Create a new parameter
+  Param (std::string name, short int type, short int flags,
+         void * eqn_val, void *matrix,
+         CValue default_init_val, CValue upper_bound,
+         CValue lower_bound);
 
-    ~Param();
+  ~Param();
 
-    /// Create a user defined floating point parameter
-    Param( std::string name );
+  /// Create a user defined floating point parameter
+  Param( std::string name );
 
-    static bool is_valid_param_string( const char *string );
-    void set_param( float val );
+  static bool is_valid_param_string( const char *string );
+  void set_param( float val );
 
-    static Param *new_param_float( const char *name, short int flags, void *engine_val,
-                             void *matrix, float upper_bound,
-                             float lower_bound,
-                             float init_val );
-    static Param *new_param_double(const char *name, short int flags, void *engine_val,
-                             void *matrix, double upper_bound,
-                             double lower_bound,
-                             double init_val );
-    static Param * new_param_int(const char * name, short int flags, void * engine_val,
-                           int upper_bound, int lower_bound, int init_val );
-    static Param * new_param_bool(const char * name, short int flags, void * engine_val,
-                            bool upper_bound, bool lower_bound, bool init_val );
-    static Param * new_param_string(const char * name, short int flags, void * engine_val);
-
+  static Param *new_param_float( const char *name, short int flags, void *engine_val,
+                                 void *matrix, float upper_bound,
+                                 float lower_bound,
+                                 float init_val );
+  static Param *new_param_double(const char *name, short int flags, void *engine_val,
+                                 void *matrix, double upper_bound,
+                                 double lower_bound,
+                                 double init_val );
+  static Param * new_param_int(const char * name, short int flags, void * engine_val,
+                               int upper_bound, int lower_bound, int init_val );
+  static Param * new_param_bool(const char * name, short int flags, void * engine_val,
+                                bool upper_bound, bool lower_bound, bool init_val );
+  static Param * new_param_string(const char * name, short int flags, void * engine_val);
 };
 
 
 /* Sets the parameter engine value to value val.
-	clipping occurs if necessary */
-inline void Param::set_param( float val) {
+  clipping occurs if necessary */
+inline void
+Param::set_param( float val)
+{
+  switch (type) {
+  case P_TYPE_BOOL:
+    if (val < 0)
+      *((bool*)engine_val) = false;
+    else if (val > 0)
+      *((bool*)engine_val) = true;
+    else
+      *((bool*)engine_val) = false;
+    break;
 
-    switch (type) {
+  case P_TYPE_INT:
+    /* Make sure value is an integer */
+    val = floor(val);
+    if (val < lower_bound.int_val)
+      *((int*)engine_val) = lower_bound.int_val;
+    else if (val > upper_bound.int_val)
+      *((int*)engine_val) = upper_bound.int_val;
+    else
+      *((int*)engine_val) = (int)val;
+    break;
 
-    case P_TYPE_BOOL:
-        if (val < 0)
-            *((bool*)engine_val) = false;
-        else if (val > 0)
-            *((bool*)engine_val) = true;
-        else
-            *((bool*)engine_val) = false;
-        break;
-    case P_TYPE_INT:
-        /* Make sure value is an integer */
-        val = floor(val);
-        if (val < lower_bound.int_val)
-            *((int*)engine_val) = lower_bound.int_val;
-        else if (val > upper_bound.int_val)
-            *((int*)engine_val) = upper_bound.int_val;
-        else
-            *((int*)engine_val) = (int)val;
-        break;
-    case P_TYPE_DOUBLE:
-        /* Make sure value is an integer */
+  case P_TYPE_DOUBLE:
+    /* Make sure value is an integer */
+    if (val < lower_bound.float_val)
+      *((float*)engine_val) = lower_bound.float_val;
+    else if (val > upper_bound.float_val)
+      *((float*)engine_val) = upper_bound.float_val;
+    else
+      *((float*)engine_val) = val;
+    break;
 
+  default:
+    //abort();
+    break;
+  }
 
-        if (val < lower_bound.float_val)
-            *((float*)engine_val) = lower_bound.float_val;
-        else if (val > upper_bound.float_val)
-            *((float*)engine_val) = upper_bound.float_val;
-        else
-            *((float*)engine_val) = val;
-        break;
-    default:
-	//abort();
-        break;
-
-    }
-
-    return;
+  return;
 }
 
 #endif /** !_PARAM_TYPES_H */
-
diff --git a/src/libprojectM/MilkdropPresetFactory/ParamUtils.hpp b/src/libprojectM/MilkdropPresetFactory/ParamUtils.hpp
index dd94ff7..2a574e4 100644
--- a/src/libprojectM/MilkdropPresetFactory/ParamUtils.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/ParamUtils.hpp
@@ -10,34 +10,33 @@
 #include <cassert>
 #include "BuiltinParams.hpp"
 
+
 class ParamUtils
 {
 public:
-  static bool insert(Param * param, std::map<std::string,Param*> * paramTree)
+  static bool
+  insert(Param * param, std::map<std::string,Param*> * paramTree)
   {
-
     assert(param);
     assert(paramTree);
 
-    
-    return ((paramTree->insert(std::make_pair(param->name,param))).second);
 
+    return ((paramTree->insert(std::make_pair(param->name,param))).second);
   }
 
   static const int AUTO_CREATE = 1;
   static const int NO_CREATE = 0;
 
-  template <int FLAGS>
-  static Param * find(std::string name, std::map<std::string,Param*> * paramTree)
+  template <int FLAGS> static Param *
+  find(std::string name, std::map<std::string,Param*> * paramTree)
   {
-
     assert(paramTree);
 
     Param * param;
 
     /* First look in the suggested database */
     std::map<std::string,Param*>::iterator pos = paramTree->find(name);
-		
+
 
     if ((FLAGS == AUTO_CREATE) && ((pos == paramTree->end())))
     {
@@ -50,26 +49,24 @@
         return NULL;
 
       /* Finally, insert the new parameter into this preset's parameter tree */
-      std::pair<std::map<std::string,Param*>::iterator, bool>  insertRetPair = 
-		paramTree->insert(std::make_pair(param->name, param));
+      std::pair<std::map<std::string,Param*>::iterator, bool>  insertRetPair =
+          paramTree->insert(std::make_pair(param->name, param));
 
       assert(insertRetPair.second);
-	
+
     } else if (pos != paramTree->end())
-	param = pos->second;
+      param = pos->second;
     else
-	param = NULL;	
+      param = NULL;
 
     /* Return the found (or created) parameter. Note that this could be null */
     return param;
-
-
   }
 
 
-  static Param * find(const std::string & name, BuiltinParams * builtinParams, std::map<std::string,Param*> * insertionTree)
+  static Param *
+  find(const std::string & name, BuiltinParams * builtinParams, std::map<std::string,Param*> * insertionTree)
   {
-
     Param * param;
 
     // Check first db
@@ -78,7 +75,6 @@
 
     // Check second db, create if necessary
     return find<AUTO_CREATE>(name, insertionTree);
-
   }
 
 };
diff --git a/src/libprojectM/MilkdropPresetFactory/Parser.cpp b/src/libprojectM/MilkdropPresetFactory/Parser.cpp
index 16c3c82..8a71f6d 100644
--- a/src/libprojectM/MilkdropPresetFactory/Parser.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/Parser.cpp
@@ -19,7 +19,6 @@
  *
  */
 /* parser.c */
-
 #include <stdio.h>
 #include <string>
 #include <cstring>
@@ -47,29 +46,31 @@
 #include <sstream>
 #include "BuiltinFuncs.hpp"
 
+
 /* Grabs the next token from the file. The second argument points
    to the raw string */
 
-line_mode_t Parser::line_mode;
-CustomWave *Parser::current_wave;
-CustomShape *Parser::current_shape;
-int Parser::string_line_buffer_index;
-char Parser::string_line_buffer[STRING_LINE_SIZE];
-unsigned int Parser::line_count;
-int Parser::per_frame_eqn_count;
-int Parser::per_frame_init_eqn_count;
-int Parser::last_custom_wave_id;
-int Parser::last_custom_shape_id;
-char Parser::last_eqn_type[MAX_TOKEN_SIZE];
-int Parser::last_token_size;
+line_mode_t   Parser::line_mode;
+CustomWave    *Parser::current_wave;
+CustomShape   *Parser::current_shape;
+int           Parser::string_line_buffer_index;
+char          Parser::string_line_buffer[STRING_LINE_SIZE];
+unsigned int  Parser::line_count;
+int           Parser::per_frame_eqn_count;
+int           Parser::per_frame_init_eqn_count;
+int           Parser::last_custom_wave_id;
+int           Parser::last_custom_shape_id;
+char          Parser::last_eqn_type[MAX_TOKEN_SIZE];
+int           Parser::last_token_size;
 
 std::string Parser::lastLinePrefix("");
 
 bool Parser::tokenWrapAroundEnabled(false);
 
-token_t Parser::parseToken(std::istream &  fs, char * string)
-{
 
+token_t
+Parser::parseToken(std::istream &  fs, char * string)
+{
   int c;
   int i;
 
@@ -128,7 +129,6 @@
             return tEOL;
           }
         }
-
       }
 
       /* Otherwise, just a regular division operator */
@@ -166,43 +166,44 @@
 
       if (tokenWrapAroundEnabled)
       {
-	std::ostringstream buffer;
+        std::ostringstream buffer;
 
         if (PARSE_DEBUG) std::cerr << "token wrap! line " << line_count << std::endl;
         while (c != '=')
         {
-
           if (!fs || fs.eof())
           {
             line_count = 1;
             line_mode = UNSET_LINE_MODE;
-        if (PARSE_DEBUG)     std::cerr << "token wrap: end of file" << std::endl;
+            if (PARSE_DEBUG)     std::cerr << "token wrap: end of file" << std::endl;
             return tEOF;
           }
-
           else {
-	    c = fs.get();
-	    if ( c != '=')
-            	buffer << (char)c;
-	}
-
+            c = fs.get();
+            if ( c != '=')
+            buffer << (char)c;
+          }
         }
-        if (PARSE_DEBUG) std::cerr << "parseToken: parsed away equal sign, line prefix is \""  << buffer.str()
-		<< "\"" << std::endl;
+
+        if (PARSE_DEBUG)
+          std::cerr << "parseToken: parsed away equal sign, line prefix is \""
+                    << buffer.str()
+                    << "\""
+                    << std::endl;
         --i;
 
-	if (!wrapsToNextLine(buffer.str())) {
-		tokenWrapAroundEnabled = false;
-		int buf_size = (int)buffer.str().length();
-		// <= to also remove equal sign parsing from stream
-		for (int k = 0; k <= buf_size; k++) {
-			if (fs)
-				fs.unget();
-			else
-				abort();
-		}
-		return tEOL;
-	}
+        if (!wrapsToNextLine(buffer.str())) {
+          tokenWrapAroundEnabled = false;
+          int buf_size = (int)buffer.str().length();
+          // <= to also remove equal sign parsing from stream
+          for (int k = 0; k <= buf_size; k++) {
+            if (fs)
+              fs.unget();
+            else
+              abort();
+          }
+          return tEOL;
+        }
 
 
         break;
@@ -228,29 +229,28 @@
     case '\r':
       i--;
       break;
-    default:
-    	if (c == EOF)
-    		std::cerr << "shouldn't happen: " << c << "(LINE " << line_count << ")" << std::endl;
-        string[i] = tolower(c);
-        //string[i+1] = 0;
-        //std::cerr << "string is \n\"" << string << "\"" << std::endl;
-      }
+      default:
+      if (c == EOF)
+        std::cerr << "shouldn't happen: " << c << "(LINE " << line_count << ")" << std::endl;
+      string[i] = tolower(c);
+      //string[i+1] = 0;
+      //std::cerr << "string is \n\"" << string << "\"" << std::endl;
+    }
 
 
   }
 
   /* String reached maximum length, return special token error */
   return tStringTooLong;
-
 }
 
 /* Parse input in the form of "exp, exp, exp, ...)"
    Returns a general expression list */
 
-GenExpr **Parser::parse_prefix_args(std::istream &  fs, int num_args, MilkdropPreset * preset)
+GenExpr **
+Parser::parse_prefix_args(std::istream &  fs, int num_args, MilkdropPreset * preset)
 {
-
-  int i, j;
+  int     i, j;
   GenExpr ** expr_list; /* List of arguments to function */
   GenExpr * gen_expr;
 
@@ -287,7 +287,8 @@
 }
 
 /* Parses a comment at the top of the file. Stops when left bracket is found */
-int Parser::parse_top_comment(std::istream &  fs)
+int
+Parser::parse_top_comment(std::istream &  fs)
 {
 
   char string[MAX_TOKEN_SIZE];
@@ -306,9 +307,9 @@
 
 /* Right Bracket is parsed by this function.
    puts a new string into name */
-int Parser::parse_preset_name(std::istream &  fs, char * name)
+int
+Parser::parse_preset_name(std::istream &  fs, char * name)
 {
-
   token_t token;
 
   if (name == NULL)
@@ -322,21 +323,18 @@
 
 
 /* Parses per pixel equations */
-int Parser::parse_per_pixel_eqn(std::istream &  fs, MilkdropPreset * preset, char * init_string)
+int
+Parser::parse_per_pixel_eqn(std::istream &  fs, MilkdropPreset * preset, char * init_string)
 {
-
-
   char string[MAX_TOKEN_SIZE];
   GenExpr * gen_expr;
 
-
   if (init_string != 0)
   {
     strncpy(string, init_string, strlen(init_string));
   }
   else
   {
-
     if (parseToken(fs, string) != tEq)
     { /* parse per pixel operator name */
       return PROJECTM_PARSE_ERROR;
@@ -364,12 +362,13 @@
 }
 
 /* Parses an equation line, this function is way too big, should add some helper functions */
-int Parser::parse_line(std::istream &  fs, MilkdropPreset * preset)
+int
+Parser::parse_line(std::istream &  fs, MilkdropPreset * preset)
 {
 
-  char eqn_string[MAX_TOKEN_SIZE];
-  token_t token;
-  InitCond * init_cond;
+  char        eqn_string[MAX_TOKEN_SIZE];
+  token_t     token;
+  InitCond    * init_cond;
   PerFrameEqn * per_frame_eqn;
 
   /* Clear the string line buffer */
@@ -379,7 +378,7 @@
   tokenWrapAroundEnabled = false;
 
   token = parseToken( fs, eqn_string );
-  switch (token )
+  switch (token)
   {
 
     /* Invalid Cases */
@@ -397,7 +396,7 @@
   case tDiv:
 
     if (PARSE_DEBUG) std::cerr << "parse_line: invalid token found at start of line (LINE "
-      << line_count << ")" << std::endl;
+    << line_count << ")" << std::endl;
 
     /* Invalid token found, return a parse error */
     return PROJECTM_PARSE_ERROR;
@@ -425,35 +424,36 @@
     if (!fs)
       return PROJECTM_PARSE_ERROR;
 
-//	char z = fs.get();
-	char tmpChar;
-	if ((tmpChar = fs.get()) == '\n') {
-		tokenWrapAroundEnabled = false;
-		return PROJECTM_PARSE_ERROR;
-	} else if (tmpChar == '\r') {
-		tokenWrapAroundEnabled = false;
-		return PROJECTM_PARSE_ERROR;
-	} else
-		fs.unget();
+    //  char z = fs.get();
+    char tmpChar;
+
+    if ((tmpChar = fs.get()) == '\n') {
+      tokenWrapAroundEnabled = false;
+      return PROJECTM_PARSE_ERROR;
+    } else if (tmpChar == '\r') {
+      tokenWrapAroundEnabled = false;
+      return PROJECTM_PARSE_ERROR;
+    } else
+      fs.unget();
 
 
 
-	/* CASE: WARP CODE */
-	if (!strncmp(eqn_string, WARP_STRING, WARP_STRING_LENGTH))
-	{
-		//std::cout << "parsing warp string block\n" << std::endl;
-		parse_string_block(fs, &preset->presetOutputs().warpShader.programSource);
-		return PROJECTM_SUCCESS;
-	}
+    /* CASE: WARP CODE */
+    if (!strncmp(eqn_string, WARP_STRING, WARP_STRING_LENGTH))
+    {
+      //std::cout << "parsing warp string block\n" << std::endl;
+      parse_string_block(fs, &preset->presetOutputs().warpShader.programSource);
+      return PROJECTM_SUCCESS;
+    }
 
 
-	/* CASE: COMPOSITE CODE */
-	if (!strncmp(eqn_string, COMPOSITE_STRING, COMPOSITE_STRING_LENGTH))
-	{
-		//std::cout << "parsing composite string block\n" << std::endl;
-		parse_string_block(fs, &preset->presetOutputs().compositeShader.programSource);
-		return PROJECTM_SUCCESS;
-	}
+    /* CASE: COMPOSITE CODE */
+    if (!strncmp(eqn_string, COMPOSITE_STRING, COMPOSITE_STRING_LENGTH))
+    {
+      //std::cout << "parsing composite string block\n" << std::endl;
+      parse_string_block(fs, &preset->presetOutputs().compositeShader.programSource);
+      return PROJECTM_SUCCESS;
+    }
 
     /* CASE: PER FRAME INIT EQUATION */
     if (!strncmp(eqn_string, PER_FRAME_INIT_STRING, PER_FRAME_INIT_STRING_LENGTH))
@@ -479,7 +479,7 @@
     /* Per frame equation case */
     if (!strncmp(eqn_string, PER_FRAME_STRING, PER_FRAME_STRING_LENGTH))
     {
-	tokenWrapAroundEnabled = true;
+      tokenWrapAroundEnabled = true;
       /* Sometimes per frame equations are implicitly defined without the
       per_frame_ prefix. This informs the parser that one could follow */
       line_mode = PER_FRAME_LINE_MODE;
@@ -504,28 +504,25 @@
     /* Wavecode initial condition case */
     if (!strncmp(eqn_string, WAVECODE_STRING, WAVECODE_STRING_LENGTH))
     {
-
       line_mode = CUSTOM_WAVE_WAVECODE_LINE_MODE;
 
       return parse_wavecode(eqn_string, fs, preset);
     }
 
     /* Custom Wave Prefix */
-    if ((!strncmp(eqn_string, WAVE_STRING, WAVE_STRING_LENGTH)) &&
-        ((eqn_string[5] >= 48) && (eqn_string[5] <= 57)))
+    if (    (!strncmp(eqn_string, WAVE_STRING, WAVE_STRING_LENGTH))
+        &&  ((eqn_string[5] >= 48)  &&  (eqn_string[5] <= 57)))
     {
-	tokenWrapAroundEnabled = true;
+      tokenWrapAroundEnabled = true;
       //    if (PARSE_DEBUG) printf("parse_line wave prefix found: \"%s\"\n", eqn_string);
 
       return parse_wave(eqn_string, fs, preset);
-
     }
 
 
     /* Shapecode initial condition case */
     if (!strncmp(eqn_string, SHAPECODE_STRING, SHAPECODE_STRING_LENGTH))
     {
-
       line_mode = CUSTOM_SHAPE_SHAPECODE_LINE_MODE;
 
       if (PARSE_DEBUG) printf("parse_line: shapecode prefix found: \"%s\"\n", eqn_string);
@@ -534,13 +531,12 @@
     }
 
     /* Custom Shape Prefix */
-    if ((!strncmp(eqn_string, SHAPE_STRING, SHAPE_STRING_LENGTH)) &&
-        ((eqn_string[6] >= 48) && (eqn_string[6] <= 57)))
+    if (    (!strncmp(eqn_string, SHAPE_STRING, SHAPE_STRING_LENGTH))
+        &&  ((eqn_string[6] >= 48)  &&  (eqn_string[6] <= 57)))
     {
       tokenWrapAroundEnabled = true;
       if (PARSE_DEBUG) printf("parse_line shape prefix found: \"%s\"\n", eqn_string);
       return parse_shape(eqn_string, fs, preset);
-
     }
 
     /* Per pixel equation case */
@@ -563,20 +559,20 @@
 
     /* Sometimes equations are written implicitly in milkdrop files, in the form
 
-    per_frame_1 = p1 = eqn1; p2 = eqn2; p3 = eqn3;..;
+       per_frame_1 = p1 = eqn1; p2 = eqn2; p3 = eqn3;..;
 
-    which is analagous to:
+       which is analagous to:
 
-    per_frame_1 = p1 = eqn1; per_frame_2 = p2 = eqn2; per_frame_3 = p3 = eqn3; ...;
+       per_frame_1 = p1 = eqn1; per_frame_2 = p2 = eqn2; per_frame_3 = p3 = eqn3; ...;
 
-    The following line mode hack allows such implicit declaration of the
-    prefix that specifies the equation type. An alternative method
-    may be to associate each equation line as list of equations separated
-    by semicolons (and a new line ends the list). Instead, however, a global
-    variable called "line_mode" specifies the last type of equation found,
-    and bases any implicitly typed input on this fact
+       The following line mode hack allows such implicit declaration of the
+       prefix that specifies the equation type. An alternative method
+       may be to associate each equation line as list of equations separated
+       by semicolons (and a new line ends the list). Instead, however, a global
+       variable called "line_mode" specifies the last type of equation found,
+       and bases any implicitly typed input on this fact
 
-    Note added by Carmelo Piccione (carmelo.piccione@gmail.com) 10/19/03
+       Note added by Carmelo Piccione (carmelo.piccione@gmail.com) 10/19/03
     */
 
     /* Per frame line mode previously, try to parse the equation implicitly */
@@ -594,7 +590,6 @@
 
 
       return PROJECTM_SUCCESS;
-
     }
     else if (line_mode == PER_FRAME_INIT_LINE_MODE)
     {
@@ -618,8 +613,6 @@
       tokenWrapAroundEnabled = true;
       if (PARSE_DEBUG) printf("parse_line: implicit per pixel eqn (LINE %d)\n", line_count);
       return parse_per_pixel_eqn(fs, preset, eqn_string);
-
-
     }
     else if (line_mode == CUSTOM_WAVE_PER_POINT_LINE_MODE)
     {
@@ -644,7 +637,6 @@
       if ((custom_wave = MilkdropPreset::find_custom_object(last_custom_wave_id, preset->customWaves)) == NULL)
         return PROJECTM_FAILURE;
       return parse_wave_per_frame_eqn(fs, custom_wave, preset);
-
     }
     else if (line_mode == CUSTOM_WAVE_WAVECODE_LINE_MODE)
     {
@@ -667,7 +659,6 @@
         return PROJECTM_FAILURE;
 
       return parse_shape_per_frame_eqn(fs, custom_shape, preset);
-
     }
     else if (line_mode == CUSTOM_SHAPE_PER_FRAME_INIT_LINE_MODE)
     {
@@ -679,7 +670,6 @@
         return PROJECTM_FAILURE;
 
       return parse_shape_per_frame_init_eqn(fs, custom_shape, preset);
-
     }
 
     if (PARSE_DEBUG) printf("parse_line: found initial condition: name = \"%s\" (LINE %d)\n", eqn_string, line_count);
@@ -713,16 +703,16 @@
 
 
 /* Parses a general expression, this function is the meat of the parser */
-GenExpr * Parser::parse_gen_expr ( std::istream &  fs, TreeExpr * tree_expr, MilkdropPreset * preset)
+GenExpr *
+Parser::parse_gen_expr ( std::istream &  fs, TreeExpr * tree_expr, MilkdropPreset * preset)
 {
-
-  int i;
-  char string[MAX_TOKEN_SIZE];
+  int     i;
+  char    string[MAX_TOKEN_SIZE];
   token_t token;
   GenExpr * gen_expr;
-  float val;
-  Param * param = NULL;
-  Func * func;
+  float   val;
+  Param   * param = NULL;
+  Func    * func;
   GenExpr ** expr_list;
 
   switch (token = parseToken(fs,string))
@@ -736,7 +726,9 @@
       if (PARSE_DEBUG)
       {
         std::cerr << "parse_gen_expr: found prefix function (name = \""
-        << func->getName() << "\") (LINE " << line_count << ")" << std::endl;
+                  << func->getName()
+                  << "\") (LINE " << line_count << ")"
+                  << std::endl;
       }
 
       /* Parse the functions arguments */
@@ -745,7 +737,8 @@
         if (PARSE_DEBUG)
         {
           std::cerr << "parse_prefix_args: failed to generate an expresion list! (LINE "
-          << line_count << ")" << std::endl;
+                    << line_count << ")"
+                    << std::endl;
         }
         if ( tree_expr != NULL )
         {
@@ -757,8 +750,8 @@
       /* Convert function to expression */
       if ((gen_expr = GenExpr::prefun_to_expr((float (*)(void *))func->func_ptr, expr_list, func->getNumArgs())) == NULL)
       {
-        if (PARSE_DEBUG) printf("parse_prefix_args: failed to convert prefix function to general expression (LINE %d) \n",
-                                  line_count);
+        if (PARSE_DEBUG)
+          printf("parse_prefix_args: failed to convert prefix function to general expression (LINE %d) \n", line_count);
         if (tree_expr)
           delete tree_expr;
         for (i = 0; i < func->getNumArgs();i++)
@@ -781,7 +774,7 @@
 
 
     /* Case 2: (Left Parentice), a string coupled with a left parentice. Either an error or implicit
-       multiplication operator. For now treat it as an error */
+    multiplication operator. For now treat it as an error */
     if (*string != 0)
     {
       std::cerr << "token prefix is " << *string << std::endl;
@@ -792,13 +785,13 @@
     }
 
     /* CASE 3 (Left Parentice): the following is enclosed parentices to change order
-       of operations. So we create a new expression tree */
+    of operations. So we create a new expression tree */
 
     if ((gen_expr = parse_gen_expr(fs, NULL, preset)) == NULL)
     {
       if (PARSE_DEBUG) printf("parse_gen_expr:  found left parentice, but failed to create new expression tree \n");
       if (tree_expr)
-      delete tree_expr;
+        delete tree_expr;
       return NULL;
     }
 
@@ -810,7 +803,6 @@
   case tPlus:
     if (*string == 0)
     {
-
       if (PARSE_DEBUG) printf("parse_gen_expr: plus used as prefix (LINE %d)\n", line_count);
 
       /* Treat prefix plus as implict 0 preceding operator */
@@ -823,7 +815,6 @@
   case tMinus:
     if (*string == 0)
     {
-
       /* Use the negative infix operator, but first add an implicit zero to the operator tree */
       gen_expr = GenExpr::const_to_expr(0);
       //return parse_gen_expr(fs, insert_gen_expr(gen_expr, &tree_expr), preset);
@@ -838,7 +829,7 @@
   case tComma:
 
     /* CASE 1 (terminal): string is empty, but not null. Not sure if this will actually happen
-       any more. */
+    any more. */
     if (*string == 0)
     {
       if (PARSE_DEBUG) printf("parse_gen_expr: empty string coupled with terminal (LINE %d) \n", line_count);
@@ -861,14 +852,13 @@
     {
       if ((gen_expr = GenExpr::const_to_expr(val)) == NULL)
       {
-        if (tree_expr)
-          delete tree_expr;
-        return NULL;
+      if (tree_expr)
+        delete tree_expr;
+      return NULL;
       }
 
       /* Parse the rest of the line */
       return parse_infix_op(fs, token, insert_gen_expr(gen_expr, &tree_expr), preset);
-
     }
 
 
@@ -881,7 +871,7 @@
           if ((param = ParamUtils::find<ParamUtils::AUTO_CREATE>(std::string(string), &current_shape->param_tree)) == NULL)
           {
             if (tree_expr)
-              delete tree_expr;
+            delete tree_expr;
             return NULL;
           }
       }
@@ -889,7 +879,8 @@
       if (PARSE_DEBUG)
       {
         std::cerr << "parse_gen_expr: custom shape parameter (name = "
-        << param->name << ")" << std::endl;
+                  << param->name << ")"
+                  << std::endl;
       }
 
 
@@ -915,7 +906,7 @@
           if ((param = ParamUtils::find<ParamUtils::AUTO_CREATE>(std::string(string), &current_wave->param_tree)) == NULL)
           {
             if (tree_expr)
-              delete tree_expr;
+            delete tree_expr;
             return NULL;
           }
       }
@@ -924,7 +915,6 @@
       if (PARSE_DEBUG)
       {
         std::cerr << "parse_gen_expr: custom wave parameter (name = " <<  param->name << ")" << std::endl;
-
       }
 
       /* Convert parameter to an expression */
@@ -938,13 +928,11 @@
 
       /* Parse the rest of the line */
       return parse_infix_op(fs, token, insert_gen_expr(gen_expr, &tree_expr), preset);
-
     }
 
     /* CASE 6: regular parameter. Will be created if necessary and the string has no invalid characters */
     if ((param = ParamUtils::find(string, &preset->builtinParams, &preset->user_param_tree)) != NULL)
     {
-
       if (PARSE_DEBUG)
       {
         std::cerr << "parse_gen_expr: parameter (name = \"" << param->name << "\")..." << std::endl;
@@ -961,14 +949,12 @@
 
       /* Parse the rest of the line */
       return parse_infix_op(fs, token, insert_gen_expr(gen_expr, &tree_expr), preset);
-
     }
 
     /* CASE 7: Bad string, give up */
     if (PARSE_DEBUG)
     {
       printf( "parse_gen_expr: syntax error [string = \"%s\"] (LINE %d)\n", string, line_count);
-
     }
     if (tree_expr)
       delete tree_expr;
@@ -981,9 +967,9 @@
 /* Inserts expressions into tree according to operator precedence.
    If root is null, a new tree is created, with infix_op as only element */
 
-TreeExpr * Parser::insert_infix_op(InfixOp * infix_op, TreeExpr **root)
+TreeExpr *
+Parser::insert_infix_op(InfixOp * infix_op, TreeExpr **root)
 {
-
   TreeExpr * new_root;
 
   /* Sanity check */
@@ -1027,13 +1013,12 @@
 
   insert_infix_rec(infix_op, *root);
   return *root;
-
 }
 
 
-TreeExpr * Parser::insert_gen_expr(GenExpr * gen_expr, TreeExpr ** root)
+TreeExpr *
+Parser::insert_gen_expr(GenExpr * gen_expr, TreeExpr ** root)
 {
-
   TreeExpr * new_root;
 
   /* If someone foolishly passes a null
@@ -1063,9 +1048,9 @@
 }
 
 /* A recursive helper function to insert general expression elements into the operator tree */
-int Parser::insert_gen_rec(GenExpr * gen_expr, TreeExpr * root)
+int
+Parser::insert_gen_rec(GenExpr * gen_expr, TreeExpr * root)
 {
-
   /* Trivial Case: root is null */
 
   if (root == NULL)
@@ -1110,9 +1095,9 @@
 
 
 /* A recursive helper function to insert infix arguments by operator precedence */
-int Parser::insert_infix_rec(InfixOp * infix_op, TreeExpr * root)
+int
+Parser::insert_infix_rec(InfixOp * infix_op, TreeExpr * root)
 {
-
   /* Shouldn't happen, implies a parse error */
 
   if (root == NULL)
@@ -1160,13 +1145,12 @@
 
   root->right = new TreeExpr(infix_op, NULL, root->right, NULL);
   return PROJECTM_SUCCESS;
-
 }
 
 /* Parses an infix operator */
-GenExpr * Parser::parse_infix_op(std::istream &  fs, token_t token, TreeExpr * tree_expr, MilkdropPreset * preset)
+GenExpr *
+Parser::parse_infix_op(std::istream &  fs, token_t token, TreeExpr * tree_expr, MilkdropPreset * preset)
 {
-
   GenExpr * gen_expr;
 
   switch (token)
@@ -1219,17 +1203,16 @@
 
   /* Will never happen */
   return NULL;
-
 }
 
 /* Parses an integer, checks for +/- prefix */
-int Parser::parse_int(std::istream &  fs, int * int_ptr)
+int
+Parser::parse_int(std::istream &  fs, int * int_ptr)
 {
-
-  char string[MAX_TOKEN_SIZE];
+  char    string[MAX_TOKEN_SIZE];
   token_t token;
-  int sign;
-  char * end_ptr = (char*)" ";
+  int     sign;
+  char    * end_ptr = (char*)" ";
 
   token = parseToken(fs, string);
 
@@ -1265,12 +1248,12 @@
     return PROJECTM_SUCCESS;
 
   return PROJECTM_PARSE_ERROR;
-
 }
-/* Parses a floating point number */
-int Parser::string_to_float(char * string, float * float_ptr)
-{
 
+/* Parses a floating point number */
+int
+Parser::string_to_float(char * string, float * float_ptr)
+{
   char ** error_ptr;
 
   if (*string == 0)
@@ -1295,13 +1278,13 @@
 }
 
 /* Parses a floating point number */
-int Parser::parse_float(std::istream &  fs, float * float_ptr)
+int
+Parser::parse_float(std::istream &  fs, float * float_ptr)
 {
-
-  char string[MAX_TOKEN_SIZE];
-  char ** error_ptr;
+  char    string[MAX_TOKEN_SIZE];
+  char    ** error_ptr;
   token_t token;
-  int sign;
+  int     sign;
 
   error_ptr =(char**) wipemalloc(sizeof(char**));
 
@@ -1344,17 +1327,16 @@
   free(error_ptr);
   error_ptr = NULL;
   return PROJECTM_PARSE_ERROR;
-
 }
 
 /* Parses a per frame equation. That is, interprets a stream of data as a per frame equation */
-PerFrameEqn * Parser::parse_per_frame_eqn(std::istream &  fs, int index, MilkdropPreset * preset)
+PerFrameEqn *
+Parser::parse_per_frame_eqn(std::istream &  fs, int index, MilkdropPreset * preset)
 {
-
-  char string[MAX_TOKEN_SIZE];
-  Param * param;
+  char        string[MAX_TOKEN_SIZE];
+  Param       * param;
   PerFrameEqn * per_frame_eqn;
-  GenExpr * gen_expr;
+  GenExpr     * gen_expr;
 
 
   if (parseToken(fs, string) != tEq)
@@ -1399,12 +1381,12 @@
 }
 
 /* Parses an 'implicit' per frame equation. That is, interprets a stream of data as a per frame equation without a prefix */
-PerFrameEqn * Parser::parse_implicit_per_frame_eqn(std::istream &  fs, char * param_string, int index, MilkdropPreset * preset)
+PerFrameEqn *
+Parser::parse_implicit_per_frame_eqn(std::istream &  fs, char * param_string, int index, MilkdropPreset * preset)
 {
-
-  Param * param;
+  Param       * param;
   PerFrameEqn * per_frame_eqn;
-  GenExpr * gen_expr;
+  GenExpr     * gen_expr;
 
   if (fs == NULL)
     return NULL;
@@ -1452,12 +1434,12 @@
 }
 
 /* Parses an initial condition */
-InitCond * Parser::parse_init_cond(std::istream &  fs, char * name, MilkdropPreset * preset)
+InitCond *
+Parser::parse_init_cond(std::istream &  fs, char * name, MilkdropPreset * preset)
 {
-
-  Param * param;
-  CValue init_val;
-  InitCond * init_cond;
+  Param     * param;
+  CValue    init_val;
+  InitCond  * init_cond;
 
   if (name == NULL)
     return NULL;
@@ -1479,7 +1461,7 @@
   }
 
   /* At this point, a parameter has been created or was found
-     in the database. */
+  in the database. */
 
   if (PARSE_DEBUG) printf("parsed_init_cond: parsing initial condition value... (LINE %d)\n", line_count);
 
@@ -1494,7 +1476,6 @@
     }
     init_val.bool_val = bool_test;
   }
-
   else if ((param->type == P_TYPE_INT))
   {
     if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR)
@@ -1503,7 +1484,6 @@
       return NULL;
     }
   }
-
   /* float value */
   else if (param->type == P_TYPE_DOUBLE)
   {
@@ -1513,7 +1493,6 @@
       return NULL;
     }
   }
-
   /* Unknown value */
   else
   {
@@ -1533,30 +1512,29 @@
 }
 
 
-void Parser::parse_string_block(std::istream &  fs, std::string * out_string) {
+void
+Parser::parse_string_block(std::istream &  fs, std::string * out_string)
+{
+  char    name[MAX_TOKEN_SIZE];
+  token_t token;
 
+  std::set<char> skipList;
+  skipList.insert('`');
+  readStringUntil(fs, out_string, false, skipList);
 
-	char name[MAX_TOKEN_SIZE];
-	token_t token;
-
-	std::set<char> skipList;
-	skipList.insert('`');
-	readStringUntil(fs, out_string, false, skipList);
-
-	//std::cout << "out_string:\n " << *out_string << "\n" << std::endl;
-
+  //std::cout << "out_string:\n " << *out_string << "\n" << std::endl;
 }
 
-InitCond * Parser::parse_per_frame_init_eqn(std::istream &  fs, MilkdropPreset * preset, std::map<std::string,Param*> * database)
+InitCond *
+Parser::parse_per_frame_init_eqn(std::istream &  fs, MilkdropPreset * preset, std::map<std::string,Param*> * database)
 {
-
-  char name[MAX_TOKEN_SIZE];
-  Param * param = NULL;
-  CValue init_val;
-  InitCond * init_cond;
-  GenExpr * gen_expr;
-  float val;
-  token_t token;
+  char      name[MAX_TOKEN_SIZE];
+  Param     * param = NULL;
+  CValue    init_val;
+  InitCond  * init_cond;
+  GenExpr   * gen_expr;
+  float     val;
+  token_t   token;
 
 
   if (preset == NULL)
@@ -1589,7 +1567,7 @@
   }
 
   /* At this point, a parameter has been created or was found
-     in the database. */
+  in the database. */
 
   if (PARSE_DEBUG) printf("parse_per_frame_init_eqn: parsing right hand side of per frame init equation.. (LINE %d)\n", line_count);
 
@@ -1610,18 +1588,15 @@
   {
     init_val.bool_val = (bool)val;
   }
-
   else if ((param->type == P_TYPE_INT))
   {
     init_val.int_val = (int)val;
   }
-
   /* float value */
   else if (param->type == P_TYPE_DOUBLE)
   {
     init_val.float_val = val;
   }
-
   /* Unknown value */
   else
   {
@@ -1643,133 +1618,130 @@
   return init_cond;
 }
 
-bool Parser::scanForComment(std::istream & fs) {
-
+bool
+Parser::scanForComment(std::istream & fs)
+{
   int c;
+
   c = fs.get();
 
   if (c == '/') {
-	while (true)
-	{
-		if (!fs || fs.eof())
-			return true;
-		else
-			c = fs.get();
-		if (c == EOF)
-			return true;
+    while (true)
+    {
+      if (!fs || fs.eof())
+        return true;
+      else
+        c = fs.get();
+      if (c == EOF)
+        return true;
 
-		if (c == '\n')
-		{
-			return true;
-		}
-	}
+      if (c == '\n')
+      {
+        return true;
+      }
+    }
   } else {
-	fs.unget();
-	return false;
+    fs.unget();
+    return false;
   }
 }
 
-void Parser::readStringUntil(std::istream & fs, std::string * out_buffer, bool wrapAround, const std::set<char> & skipList) {
-
-	int string_line_buffer_index = 0;
-	int c;
-
-	/* Loop until a delimiter is found, or the maximum string size is found */
-	while (true)
-	{
-
-		if (!fs || fs.eof())
-			c = EOF;
-		else
-			c = fs.get();
-
-		/* Now interpret the character */
-		switch (c)
-		{
-			case '/':
-			{
-				bool commentExisted = scanForComment(fs);
-				if (!commentExisted) {
-					out_buffer->push_back(c);
-					break;
-				} else {
-					line_count++;
-					return;
-				}
-			}
-			case '\n':
-				if (!out_buffer->empty() && ((*out_buffer)[out_buffer->length() -1] == '\n'))
-					return;
-
-				line_count++;
-				if (wrapAround)
-				{
-					std::ostringstream buffer;
-
-		//			if (PARSE_DEBUG) std::cerr << "token wrap! line " << line_count << std::endl;
-					while (c != '=')
-					{
-
-						if (!fs || fs.eof())
-						{
-							line_count = 1;
-							line_mode = UNSET_LINE_MODE;
-		//					if (PARSE_DEBUG)     std::cerr << "token wrap: end of file" << std::endl;
-							return;
-						}
-
-						else {
-							c = fs.get();
-							if ( c != '=')
-								buffer << c;
-						}
-
-					}
-
-
-					if (!wrapsToNextLine(buffer.str())) {
-						wrapAround = false;
-						int buf_size = (int)buffer.str().length();
-						// <= to also remove equal sign parsing from stream
-						for (int k = 0; k <= buf_size; k++) {
-							if (fs)
-								fs.unget();
-							else
-								abort();
-						}
-						return;
-					}
-
-					break;
-				} else
-					out_buffer->push_back(c);
-				return;
-			case EOF:
-				line_count = 1;
-				return;
-			default:
-
-				if (out_buffer != NULL)
-				{
-					if (skipList.find(c) == skipList.end())
-						out_buffer->push_back(c);
-
-				}
-		}
-
-	}
-
-
-}
-int Parser::parse_wavecode(char * token, std::istream &  fs, MilkdropPreset * preset)
+void
+Parser::readStringUntil(std::istream & fs, std::string * out_buffer, bool wrapAround, const std::set<char> & skipList)
 {
+  int string_line_buffer_index = 0;
+  int c;
 
-  char * var_string;
-  InitCond * init_cond;
-  CustomWave * custom_wave;
-  int id;
-  CValue init_val;
-  Param * param;
+  /* Loop until a delimiter is found, or the maximum string size is found */
+  while (true)
+  {
+    if (!fs || fs.eof())
+      c = EOF;
+    else
+      c = fs.get();
+
+    /* Now interpret the character */
+    switch (c)
+    {
+    case '/':
+      {
+        bool commentExisted = scanForComment(fs);
+
+        if (!commentExisted) {
+          out_buffer->push_back(c);
+          break;
+        } else {
+          line_count++;
+          return;
+        }
+      }
+    case '\n':
+      if (!out_buffer->empty() && ((*out_buffer)[out_buffer->length() -1] == '\n'))
+        return;
+
+      line_count++;
+      if (wrapAround)
+      {
+        std::ostringstream buffer;
+
+        //      if (PARSE_DEBUG) std::cerr << "token wrap! line " << line_count << std::endl;
+        while (c != '=')
+        {
+          if (!fs || fs.eof())
+          {
+            line_count = 1;
+            line_mode = UNSET_LINE_MODE;
+            //          if (PARSE_DEBUG)     std::cerr << "token wrap: end of file" << std::endl;
+            return;
+          }
+          else {
+            c = fs.get();
+            if ( c != '=')
+              buffer << c;
+          }
+        }
+
+
+        if (!wrapsToNextLine(buffer.str())) {
+          wrapAround = false;
+          int buf_size = (int)buffer.str().length();
+          // <= to also remove equal sign parsing from stream
+          for (int k = 0; k <= buf_size; k++) {
+            if (fs)
+              fs.unget();
+            else
+              abort();
+          }
+          return;
+        }
+
+        break;
+      } else
+        out_buffer->push_back(c);
+      return;
+    case EOF:
+      line_count = 1;
+      return;
+    default:
+
+      if (out_buffer != NULL)
+      {
+        if (skipList.find(c) == skipList.end())
+          out_buffer->push_back(c);
+      }
+    }
+  }
+}
+
+int
+Parser::parse_wavecode(char * token, std::istream &  fs, MilkdropPreset * preset)
+{
+  char        * var_string;
+  InitCond    * init_cond;
+  CustomWave  * custom_wave;
+  int         id;
+  CValue      init_val;
+  Param       * param;
 
   assert(preset);
   assert(fs);
@@ -1789,7 +1761,8 @@
   if ((custom_wave = MilkdropPreset::find_custom_object(id, preset->customWaves)) == NULL)
   {
     std::cerr << "parse_wavecode: failed to load (or create) custom wave (id = "
-    << id << ")!\n" << std::endl;
+              << id << ")!\n"
+              << std::endl;
 
     return PROJECTM_FAILURE;
   }
@@ -1807,9 +1780,9 @@
   if ((param->type == P_TYPE_BOOL))
   {
     int bool_test;
+
     if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR)
     {
-
       if (PARSE_DEBUG) printf("parse_wavecode: error parsing integer!\n");
       return PROJECTM_PARSE_ERROR;
     }
@@ -1819,12 +1792,10 @@
   {
     if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR)
     {
-
       if (PARSE_DEBUG) printf("parse_wavecode: error parsing integer!\n");
       return PROJECTM_PARSE_ERROR;
     }
   }
-
   /* float value */
   else if (param->type == P_TYPE_DOUBLE)
   {
@@ -1834,7 +1805,6 @@
       return PROJECTM_PARSE_ERROR;
     }
   }
-
   /* Unknown value */
   else
   {
@@ -1852,9 +1822,9 @@
   }
 
   std::pair<std::map<std::string, InitCond*>::iterator, bool> inserteePair =
-    custom_wave->init_cond_tree.insert(std::make_pair(init_cond->param->name, init_cond));
+      custom_wave->init_cond_tree.insert(std::make_pair(init_cond->param->name, init_cond));
 
- // assert(inserteePair.second);
+  // assert(inserteePair.second);
 
   line_mode = CUSTOM_WAVE_WAVECODE_LINE_MODE;
 
@@ -1862,15 +1832,16 @@
   return PROJECTM_SUCCESS;
 }
 
-int Parser::parse_shapecode(char * token, std::istream &  fs, MilkdropPreset * preset)
+int
+Parser::parse_shapecode(char * token, std::istream &  fs, MilkdropPreset * preset)
 {
 
-  char * var_string;
-  InitCond * init_cond;
+  char        * var_string;
+  InitCond    * init_cond;
   CustomShape * custom_shape;
-  int id;
-  CValue init_val;
-  Param * param;
+  int         id;
+  CValue      init_val;
+  Param       * param;
 
   /* Null argument checks */
   if (preset == NULL)
@@ -1892,7 +1863,7 @@
 
 
   /* Retrieve custom shape information from preset. The 3rd argument
-     if true creates a custom shape if one does not exist */
+  if true creates a custom shape if one does not exist */
 
   if ((custom_shape = MilkdropPreset::find_custom_object(id,  preset->customShapes)) == NULL)
   {
@@ -1903,7 +1874,6 @@
 
   if ((param = ParamUtils::find<ParamUtils::NO_CREATE>(var_string, &custom_shape->text_properties_tree)) != NULL)
   {
-
     std::string text;//[MAX_TOKEN_SIZE];
     //token_t token = parseToken(fs, text);
 
@@ -1912,7 +1882,8 @@
     *((std::string*)param->engine_val) = text;
     if (PARSE_DEBUG)
       std::cerr << "parse_shapecode: found image url, text is \""
-      << text << "\"" << std::endl;
+                << text << "\""
+                << std::endl;
 
     return PROJECTM_SUCCESS;
   }
@@ -1933,6 +1904,7 @@
   if ((param->type == P_TYPE_BOOL))
   {
     int bool_test;
+
     if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR)
     {
       if (PARSE_DEBUG) printf("parse_shapecode: error parsing integer!\n");
@@ -1948,7 +1920,6 @@
       return PROJECTM_PARSE_ERROR;
     }
   }
-
   /* float value */
   else if (param->type == P_TYPE_DOUBLE)
   {
@@ -1958,7 +1929,6 @@
       return PROJECTM_PARSE_ERROR;
     }
   }
-
   /* Unknown value */
   else
   {
@@ -1981,9 +1951,9 @@
 }
 
 
-int Parser::parse_wavecode_prefix(char * token, int * id, char ** var_string)
+int
+Parser::parse_wavecode_prefix(char * token, int * id, char ** var_string)
 {
-
   int len, i, j;
 
   if (token == NULL)
@@ -2022,13 +1992,12 @@
   *var_string = token + i + 1;
 
   return PROJECTM_SUCCESS;
-
 }
 
 
-int Parser::parse_shapecode_prefix(char * token, int * id, char ** var_string)
+int
+Parser::parse_shapecode_prefix(char * token, int * id, char ** var_string)
 {
-
   int len, i, j;
 
   if (token == NULL)
@@ -2067,12 +2036,11 @@
   *var_string = token + i + 1;
 
   return PROJECTM_SUCCESS;
-
 }
 
-int Parser::parse_wave_prefix(char * token, int * id, char ** eqn_string)
+int
+Parser::parse_wave_prefix(char * token, int * id, char ** eqn_string)
 {
-
   int len, i, j;
 
   if (token == NULL)
@@ -2110,12 +2078,11 @@
 
   if (PARSE_DEBUG) printf("parse_wave_prefix: prefix = %s\n (LINE %d)", *eqn_string, line_count);
   return PROJECTM_SUCCESS;
-
 }
 
-int Parser::parse_shape_prefix(char * token, int * id, char ** eqn_string)
+int
+Parser::parse_shape_prefix(char * token, int * id, char ** eqn_string)
 {
-
   int len, i, j;
 
   if (token == NULL)
@@ -2152,15 +2119,14 @@
   *eqn_string = token + i + 1;
 
   return PROJECTM_SUCCESS;
-
 }
 
 /* Parses custom wave equations */
-int Parser::parse_wave(char * token, std::istream &  fs, MilkdropPreset * preset)
+int
+Parser::parse_wave(char * token, std::istream &  fs, MilkdropPreset * preset)
 {
-
-  int id;
-  char * eqn_type;
+  int   id;
+  char  * eqn_type;
 
   if (PARSE_DEBUG) printf("parse_wave:begin\n");
 
@@ -2181,18 +2147,17 @@
   strncpy(last_eqn_type, eqn_type, MAX_TOKEN_SIZE);
 
   return parse_wave_helper(fs, preset, id, eqn_type, 0);
-
 }
 
-int Parser::parse_wave_helper(std::istream &  fs, MilkdropPreset  * preset, int id, char * eqn_type, char * init_string)
+int
+Parser::parse_wave_helper(std::istream &  fs, MilkdropPreset  * preset, int id, char * eqn_type, char * init_string)
 {
-
-  Param * param;
-  GenExpr * gen_expr;
-  char string[MAX_TOKEN_SIZE];
+  Param       * param;
+  GenExpr     * gen_expr;
+  char        string[MAX_TOKEN_SIZE];
   PerFrameEqn * per_frame_eqn;
-  CustomWave * custom_wave;
-  InitCond * init_cond;
+  CustomWave  * custom_wave;
+  InitCond    * init_cond;
 
   /* Retrieve custom wave associated with this id */
   if ((custom_wave = MilkdropPreset::find_custom_object(id,  preset->customWaves)) == NULL)
@@ -2204,7 +2169,6 @@
   /* per frame init equation case */
   if (!strncmp(eqn_type, WAVE_INIT_STRING, WAVE_INIT_STRING_LENGTH))
   {
-
     if (PARSE_DEBUG) printf("parse_wave_helper (per frame init): [begin] (LINE %d)\n", line_count);
 
     /* Parse the per frame init equation */
@@ -2220,13 +2184,11 @@
     line_mode = CUSTOM_WAVE_PER_FRAME_INIT_LINE_MODE;
     init_cond->evaluate(true);
     return PROJECTM_SUCCESS;
-
   }
 
   /* per frame equation case */
   if (!strncmp(eqn_type, PER_FRAME_STRING_NO_UNDERSCORE, PER_FRAME_STRING_NO_UNDERSCORE_LENGTH))
   {
-
     if (PARSE_DEBUG) printf("parse_wave_helper (per_frame): [start] (custom wave id = %d)\n", custom_wave->id);
 
     if (parseToken(fs, string) != tEq)
@@ -2275,11 +2237,11 @@
 
     custom_wave->per_frame_eqn_tree.push_back(per_frame_eqn);
     if (PARSE_DEBUG) printf("parse_wave (per_frame): equation %d associated with custom wave %d [success]\n",
-                              per_frame_eqn->index, custom_wave->id);
+                            per_frame_eqn->index, custom_wave->id);
 
 
     /* Need to add stuff to string buffer so the editor can read the equations.
-       Why not make a nice little helper function for this? - here it is: */
+    Why not make a nice little helper function for this? - here it is: */
 
     line_mode = CUSTOM_WAVE_PER_FRAME_LINE_MODE;
     return PROJECTM_SUCCESS;
@@ -2289,7 +2251,6 @@
   /* per point equation case */
   if (!strncmp(eqn_type, PER_POINT_STRING, PER_POINT_STRING_LENGTH))
   {
-
     if (PARSE_DEBUG) printf("parse_wave_helper (per_point): per_pixel equation parsing start...(LINE %d)\n", line_count);
 
     /// HACK the parse_line code already parsed the per_pixel variable name. This handles that case
@@ -2337,16 +2298,15 @@
 }
 
 /* Parses custom shape equations */
-int Parser::parse_shape(char * token, std::istream &  fs, MilkdropPreset * preset)
+int
+Parser::parse_shape(char * token, std::istream &  fs, MilkdropPreset * preset)
 {
-
-  int id;
-  char * eqn_type;
+  int         id;
+  char        * eqn_type;
   CustomShape * custom_shape;
 
 
   if (token == NULL)
-
     return PROJECTM_FAILURE;
   if (fs == NULL)
     return PROJECTM_FAILURE;
@@ -2392,9 +2352,9 @@
    Returns -1 if syntax error
 */
 
-int Parser::get_string_prefix_len(char * string)
+int
+Parser::get_string_prefix_len(char * string)
 {
-
   int i = 0;
 
   /* Null argument check */
@@ -2430,7 +2390,8 @@
   return i;
 }
 
-int Parser::parse_shape_per_frame_init_eqn(std::istream &  fs, CustomShape * custom_shape, MilkdropPreset * preset)
+int
+Parser::parse_shape_per_frame_init_eqn(std::istream &  fs, CustomShape * custom_shape, MilkdropPreset * preset)
 {
   InitCond * init_cond;
 
@@ -2450,11 +2411,11 @@
   return PROJECTM_SUCCESS;
 }
 
-int Parser::parse_shape_per_frame_eqn(std::istream & fs, CustomShape * custom_shape, MilkdropPreset * preset)
+int
+Parser::parse_shape_per_frame_eqn(std::istream & fs, CustomShape * custom_shape, MilkdropPreset * preset)
 {
-
-  Param * param;
-  GenExpr * gen_expr;
+  Param       * param;
+  GenExpr     * gen_expr;
   PerFrameEqn * per_frame_eqn;
 
   char string[MAX_TOKEN_SIZE];
@@ -2512,11 +2473,11 @@
   return PROJECTM_SUCCESS;
 }
 
-int Parser::parse_wave_per_frame_eqn(std::istream &  fs, CustomWave * custom_wave, MilkdropPreset * preset)
+int
+Parser::parse_wave_per_frame_eqn(std::istream &  fs, CustomWave * custom_wave, MilkdropPreset * preset)
 {
-
-  Param * param;
-  GenExpr * gen_expr;
+  Param       * param;
+  GenExpr     * gen_expr;
   PerFrameEqn * per_frame_eqn;
 
   char string[MAX_TOKEN_SIZE];
@@ -2568,29 +2529,26 @@
 
   custom_wave->per_frame_eqn_tree.push_back(per_frame_eqn);
   if (PARSE_DEBUG) printf("parse_wave (per_frame): equation %d associated with custom wave %d [success]\n",
-                            per_frame_eqn->index, custom_wave->id);
+                          per_frame_eqn->index, custom_wave->id);
 
 
   /* Need to add stuff to string buffer so the editor can read the equations.
-     Why not make a nice little helper function for this? - here it is: */
+  Why not make a nice little helper function for this? - here it is: */
 
   line_mode = CUSTOM_WAVE_PER_FRAME_LINE_MODE;
   return PROJECTM_SUCCESS;
 }
 
 
-bool Parser::wrapsToNextLine(const std::string & str) {
+bool
+Parser::wrapsToNextLine(const std::string & str)
+{
+  std::size_t lastLineEndIndex = lastLinePrefix.find_last_not_of("0123456789");
+  std::size_t thisLineEndIndex = str.find_last_not_of("0123456789");
+  std::size_t startIndex = 0;
 
-std::size_t lastLineEndIndex =
-	lastLinePrefix.find_last_not_of("0123456789");
-
-std::size_t thisLineEndIndex =
-	str.find_last_not_of("0123456789");
-
-std::size_t startIndex = 0;
-if ((str.compare(startIndex, lastLineEndIndex, lastLinePrefix.c_str(), thisLineEndIndex)) == 0)
-	return true;
-else
-	return false;
-
+  if ((str.compare(startIndex, lastLineEndIndex, lastLinePrefix.c_str(), thisLineEndIndex)) == 0)
+    return true;
+  else
+    return false;
 }
diff --git a/src/libprojectM/MilkdropPresetFactory/Parser.hpp b/src/libprojectM/MilkdropPresetFactory/Parser.hpp
index 8c0e19d..f9ff507 100644
--- a/src/libprojectM/MilkdropPresetFactory/Parser.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/Parser.hpp
@@ -25,9 +25,9 @@
  *
  * $Log$
  */
-
 #ifndef _PARSER_H
 #define _PARSER_H
+
 //#define PARSE_DEBUG 2
 #define PARSE_DEBUG 0
 
@@ -38,46 +38,47 @@
 #include "InitCond.hpp"
 #include "MilkdropPreset.hpp"
 
+
 /* Strings that prefix (and denote the type of) equations */
-#define PER_FRAME_STRING "per_frame_"
-#define PER_FRAME_STRING_LENGTH 10
+#define PER_FRAME_STRING                      "per_frame_"
+#define PER_FRAME_STRING_LENGTH               10
 
-#define PER_PIXEL_STRING "per_pixel_"
-#define PER_PIXEL_STRING_LENGTH 10
+#define PER_PIXEL_STRING                      "per_pixel_"
+#define PER_PIXEL_STRING_LENGTH               10
 
-#define PER_FRAME_INIT_STRING "per_frame_init_"
-#define PER_FRAME_INIT_STRING_LENGTH 15
+#define PER_FRAME_INIT_STRING                 "per_frame_init_"
+#define PER_FRAME_INIT_STRING_LENGTH          15
 
-#define WAVECODE_STRING "wavecode_"
-#define WAVECODE_STRING_LENGTH 9
+#define WAVECODE_STRING                       "wavecode_"
+#define WAVECODE_STRING_LENGTH                9
 
-#define WAVE_STRING "wave_"
-#define WAVE_STRING_LENGTH 5
+#define WAVE_STRING                           "wave_"
+#define WAVE_STRING_LENGTH                    5
 
-#define PER_POINT_STRING "per_point"
-#define PER_POINT_STRING_LENGTH 9
+#define PER_POINT_STRING                      "per_point"
+#define PER_POINT_STRING_LENGTH               9
 
-#define PER_FRAME_STRING_NO_UNDERSCORE "per_frame"
+#define PER_FRAME_STRING_NO_UNDERSCORE        "per_frame"
 #define PER_FRAME_STRING_NO_UNDERSCORE_LENGTH 9
 
-#define SHAPECODE_STRING "shapecode_"
-#define SHAPECODE_STRING_LENGTH 10
+#define SHAPECODE_STRING                      "shapecode_"
+#define SHAPECODE_STRING_LENGTH               10
 
 
-#define WARP_STRING "warp_"
-#define WARP_STRING_LENGTH 5
+#define WARP_STRING                           "warp_"
+#define WARP_STRING_LENGTH                    5
 
-#define COMPOSITE_STRING "comp_"
-#define COMPOSITE_STRING_LENGTH 5
+#define COMPOSITE_STRING                      "comp_"
+#define COMPOSITE_STRING_LENGTH               5
 
-#define SHAPE_STRING "shape_"
-#define SHAPE_STRING_LENGTH 6
+#define SHAPE_STRING                          "shape_"
+#define SHAPE_STRING_LENGTH                   6
 
-#define SHAPE_INIT_STRING "init"
-#define SHAPE_INIT_STRING_LENGTH 4
+#define SHAPE_INIT_STRING                     "init"
+#define SHAPE_INIT_STRING_LENGTH              4
 
-#define WAVE_INIT_STRING "init"
-#define WAVE_INIT_STRING_LENGTH 4
+#define WAVE_INIT_STRING                      "init"
+#define WAVE_INIT_STRING_LENGTH               4
 
 #include <set>
 
@@ -98,27 +99,27 @@
 
 /** Token enumeration type */
 typedef enum {
-    tEOL,   /* end of a line, usually a '/n' or '/r' */
-    tEOF,   /* end of file */
-    tLPr,   /* ( */
-    tRPr,   /* ) */
-    tLBr,   /* [ */
-    tRBr,   /* ] */
-    tEq,    /* = */
-    tPlus,  /* + */
-    tMinus, /* - */
-    tMult,  /* * */
-    tMod,   /* % */
-    tDiv,   /* / */
-    tOr,    /* | */
-    tAnd,   /* & */
-    tComma, /* , */
-    tPositive, /* + as a prefix operator */
-    tNegative, /* - as a prefix operator */
-    tSemiColon, /* ; */
-    tStringTooLong, /* special token to indicate an invalid string length */
-    tStringBufferFilled /* the string buffer for this line is maxed out */
-  } token_t;
+  tEOL,   /* end of a line, usually a '/n' or '/r' */
+  tEOF,   /* end of file */
+  tLPr,   /* ( */
+  tRPr,   /* ) */
+  tLBr,   /* [ */
+  tRBr,   /* ] */
+  tEq,    /* = */
+  tPlus,  /* + */
+  tMinus, /* - */
+  tMult,  /* * */
+  tMod,   /* % */
+  tDiv,   /* / */
+  tOr,    /* | */
+  tAnd,   /* & */
+  tComma, /* , */
+  tPositive, /* + as a prefix operator */
+  tNegative, /* - as a prefix operator */
+  tSemiColon, /* ; */
+  tStringTooLong, /* special token to indicate an invalid string length */
+  tStringBufferFilled /* the string buffer for this line is maxed out */
+} token_t;
 
 class CustomShape;
 class CustomWave;
@@ -130,63 +131,62 @@
 
 class Parser {
 public:
-    static std::string lastLinePrefix;
-    static line_mode_t line_mode;
-    static CustomWave *current_wave;
-    static CustomShape *current_shape;
-    static int string_line_buffer_index;
-    static char string_line_buffer[STRING_LINE_SIZE];
-    static unsigned int line_count;
-    static int per_frame_eqn_count;
-    static int per_frame_init_eqn_count;
-    static int last_custom_wave_id;
-    static int last_custom_shape_id;
-    static char last_eqn_type[MAX_TOKEN_SIZE];
-    static int last_token_size;
-    static bool tokenWrapAroundEnabled;
+  static std::string lastLinePrefix;
+  static line_mode_t line_mode;
+  static CustomWave *current_wave;
+  static CustomShape *current_shape;
+  static int string_line_buffer_index;
+  static char string_line_buffer[STRING_LINE_SIZE];
+  static unsigned int line_count;
+  static int per_frame_eqn_count;
+  static int per_frame_init_eqn_count;
+  static int last_custom_wave_id;
+  static int last_custom_shape_id;
+  static char last_eqn_type[MAX_TOKEN_SIZE];
+  static int last_token_size;
+  static bool tokenWrapAroundEnabled;
 
-    static PerFrameEqn *parse_per_frame_eqn( std::istream & fs, int index,
-                                             MilkdropPreset * preset);
-    static int parse_per_pixel_eqn( std::istream & fs, MilkdropPreset * preset,
-                                    char * init_string);
-    static InitCond *parse_init_cond( std::istream & fs, char * name, MilkdropPreset * preset );
-    static int parse_preset_name( std::istream & fs, char * name );
-    static int parse_top_comment( std::istream & fs );
-    static int parse_line( std::istream & fs, MilkdropPreset * preset );
+  static PerFrameEqn *parse_per_frame_eqn( std::istream & fs, int index,
+                                           MilkdropPreset * preset);
+  static int parse_per_pixel_eqn( std::istream & fs, MilkdropPreset * preset,
+                                  char * init_string);
+  static InitCond *parse_init_cond( std::istream & fs, char * name, MilkdropPreset * preset );
+  static int parse_preset_name( std::istream & fs, char * name );
+  static int parse_top_comment( std::istream & fs );
+  static int parse_line( std::istream & fs, MilkdropPreset * preset );
 
-    static int get_string_prefix_len(char * string);
-    static TreeExpr * insert_gen_expr(GenExpr * gen_expr, TreeExpr ** root);
-    static TreeExpr * insert_infix_op(InfixOp * infix_op, TreeExpr ** root);
-    static token_t parseToken(std::istream & fs, char * string);
-    static GenExpr ** parse_prefix_args(std::istream & fs, int num_args, MilkdropPreset * preset);
-    static GenExpr * parse_infix_op(std::istream & fs, token_t token, TreeExpr * tree_expr, MilkdropPreset * preset);
-    static GenExpr * parse_sign_arg(std::istream & fs);
-    static int parse_float(std::istream & fs, float * float_ptr);
-    static int parse_int(std::istream & fs, int * int_ptr);
-    static int insert_gen_rec(GenExpr * gen_expr, TreeExpr * root);
-    static int insert_infix_rec(InfixOp * infix_op, TreeExpr * root);
-    static GenExpr * parse_gen_expr(std::istream & fs, TreeExpr * tree_expr, MilkdropPreset * preset);
-    static PerFrameEqn * parse_implicit_per_frame_eqn(std::istream & fs, char * param_string, int index, MilkdropPreset * preset);
-    static InitCond * parse_per_frame_init_eqn(std::istream & fs, MilkdropPreset * preset, std::map<std::string,Param*> * database);
-    static int parse_wavecode_prefix(char * token, int * id, char ** var_string);
-    static int parse_wavecode(char * token, std::istream & fs, MilkdropPreset * preset);
-    static int parse_wave_prefix(char * token, int * id, char ** eqn_string);
-    static int parse_wave_helper(std::istream & fs, MilkdropPreset * preset, int id, char * eqn_type, char * init_string);
-    static int parse_shapecode(char * eqn_string, std::istream & fs, MilkdropPreset * preset);
-    static int parse_shapecode_prefix(char * token, int * id, char ** var_string);
-    static void parse_string_block(std::istream &  fs, std::string * out_string);
-    static bool scanForComment(std::istream & fs);
-    static int parse_wave(char * eqn_string, std::istream & fs, MilkdropPreset * preset);
-    static int parse_shape(char * eqn_string, std::istream & fs, MilkdropPreset * preset);
-    static int parse_shape_prefix(char * token, int * id, char ** eqn_string);
-    static void readStringUntil(std::istream & fs, std::string * out_buffer, bool wrapAround = true, const std::set<char> & skipList = std::set<char>()) ;
+  static int get_string_prefix_len(char * string);
+  static TreeExpr * insert_gen_expr(GenExpr * gen_expr, TreeExpr ** root);
+  static TreeExpr * insert_infix_op(InfixOp * infix_op, TreeExpr ** root);
+  static token_t parseToken(std::istream & fs, char * string);
+  static GenExpr ** parse_prefix_args(std::istream & fs, int num_args, MilkdropPreset * preset);
+  static GenExpr * parse_infix_op(std::istream & fs, token_t token, TreeExpr * tree_expr, MilkdropPreset * preset);
+  static GenExpr * parse_sign_arg(std::istream & fs);
+  static int parse_float(std::istream & fs, float * float_ptr);
+  static int parse_int(std::istream & fs, int * int_ptr);
+  static int insert_gen_rec(GenExpr * gen_expr, TreeExpr * root);
+  static int insert_infix_rec(InfixOp * infix_op, TreeExpr * root);
+  static GenExpr * parse_gen_expr(std::istream & fs, TreeExpr * tree_expr, MilkdropPreset * preset);
+  static PerFrameEqn * parse_implicit_per_frame_eqn(std::istream & fs, char * param_string, int index, MilkdropPreset * preset);
+  static InitCond * parse_per_frame_init_eqn(std::istream & fs, MilkdropPreset * preset, std::map<std::string,Param*> * database);
+  static int parse_wavecode_prefix(char * token, int * id, char ** var_string);
+  static int parse_wavecode(char * token, std::istream & fs, MilkdropPreset * preset);
+  static int parse_wave_prefix(char * token, int * id, char ** eqn_string);
+  static int parse_wave_helper(std::istream & fs, MilkdropPreset * preset, int id, char * eqn_type, char * init_string);
+  static int parse_shapecode(char * eqn_string, std::istream & fs, MilkdropPreset * preset);
+  static int parse_shapecode_prefix(char * token, int * id, char ** var_string);
+  static void parse_string_block(std::istream &  fs, std::string * out_string);
+  static bool scanForComment(std::istream & fs);
+  static int parse_wave(char * eqn_string, std::istream & fs, MilkdropPreset * preset);
+  static int parse_shape(char * eqn_string, std::istream & fs, MilkdropPreset * preset);
+  static int parse_shape_prefix(char * token, int * id, char ** eqn_string);
+  static void readStringUntil(std::istream & fs, std::string * out_buffer, bool wrapAround = true, const std::set<char> & skipList = std::set<char>()) ;
 
-    static int string_to_float(char * string, float * float_ptr);
-    static int parse_shape_per_frame_init_eqn(std::istream & fs, CustomShape * custom_shape, MilkdropPreset * preset);
-    static int parse_shape_per_frame_eqn(std::istream & fs, CustomShape * custom_shape, MilkdropPreset * preset);
-    static int parse_wave_per_frame_eqn(std::istream & fs, CustomWave * custom_wave, MilkdropPreset * preset);
-    static bool wrapsToNextLine(const std::string & str);
-  };
+  static int string_to_float(char * string, float * float_ptr);
+  static int parse_shape_per_frame_init_eqn(std::istream & fs, CustomShape * custom_shape, MilkdropPreset * preset);
+  static int parse_shape_per_frame_eqn(std::istream & fs, CustomShape * custom_shape, MilkdropPreset * preset);
+  static int parse_wave_per_frame_eqn(std::istream & fs, CustomWave * custom_wave, MilkdropPreset * preset);
+  static bool wrapsToNextLine(const std::string & str);
+};
 
 #endif /** !_PARSER_H */
-
diff --git a/src/libprojectM/MilkdropPresetFactory/PerFrameEqn.cpp b/src/libprojectM/MilkdropPresetFactory/PerFrameEqn.cpp
index 30e2342..96bd10f 100644
--- a/src/libprojectM/MilkdropPresetFactory/PerFrameEqn.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/PerFrameEqn.cpp
@@ -18,7 +18,6 @@
  * See 'LICENSE.txt' included within this release
  *
  */
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -35,33 +34,33 @@
 #include "wipemalloc.h"
 #include <cassert>
 
+
 /* Evaluate an equation */
-void PerFrameEqn::evaluate() {
+void
+PerFrameEqn::evaluate()
+{
+  if (PER_FRAME_EQN_DEBUG) {
+    printf("per_frame_%d=%s= ", index, param->name.c_str());
+    fflush(stdout);
+  }
 
-     if (PER_FRAME_EQN_DEBUG) { 
-		 printf("per_frame_%d=%s= ", index, param->name.c_str());
-		 fflush(stdout); 
-     }
-	 
-    //*((float*)per_frame_eqn->param->engine_val) = eval_gen_expr(per_frame_eqn->gen_expr);
-	assert(gen_expr);
-	assert(param);
-	param->set_param(gen_expr->eval_gen_expr(-1,-1));
+  //*((float*)per_frame_eqn->param->engine_val) = eval_gen_expr(per_frame_eqn->gen_expr);
+  assert(gen_expr);
+  assert(param);
+  param->set_param(gen_expr->eval_gen_expr(-1,-1));
 
-     if (PER_FRAME_EQN_DEBUG) printf(" = %.4f\n", *((float*)param->engine_val)); 
-		 
+  if (PER_FRAME_EQN_DEBUG) printf(" = %.4f\n", *((float*)param->engine_val));
 }
 
 
 /* Frees perframe equation structure. Warning: assumes gen_expr pointer is not freed by anyone else! */
-PerFrameEqn::~PerFrameEqn() {
-
+PerFrameEqn::~PerFrameEqn()
+{
   delete gen_expr;
 
   // param is freed in param_tree container of some other class
-
 }
 
 /* Create a new per frame equation */
-PerFrameEqn::PerFrameEqn(int _index, Param * _param, GenExpr * _gen_expr) :
-	index(_index), param(_param), gen_expr(_gen_expr) {}
+PerFrameEqn::PerFrameEqn(int _index, Param * _param, GenExpr * _gen_expr)
+  : index(_index), param(_param), gen_expr(_gen_expr) {}
diff --git a/src/libprojectM/MilkdropPresetFactory/PerFrameEqn.hpp b/src/libprojectM/MilkdropPresetFactory/PerFrameEqn.hpp
index 3964080..155560f 100644
--- a/src/libprojectM/MilkdropPresetFactory/PerFrameEqn.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/PerFrameEqn.hpp
@@ -29,25 +29,27 @@
 #ifndef _PER_FRAME_EQN_H
 #define _PER_FRAME_EQN_H
 
+
 #define PER_FRAME_EQN_DEBUG 0
 
+
 class GenExpr;
 class Param;
 class PerFrameEqn;
 
 class PerFrameEqn {
 public:
-    int index; /* a unique id for each per frame eqn (generated by order in preset files) */
-    Param *param; /* parameter to be assigned a value */
-    GenExpr *gen_expr;   /* expression that paremeter is equal to */
-     
-    PerFrameEqn(int index, Param * param, GenExpr * gen_expr);
-    ~PerFrameEqn();
+  int index; /* a unique id for each per frame eqn (generated by order in preset files) */
+  Param *param; /* parameter to be assigned a value */
+  GenExpr *gen_expr;   /* expression that paremeter is equal to */
 
-    /// Evaluate the per frame equation
-    void evaluate();
+  PerFrameEqn(int index, Param * param, GenExpr * gen_expr);
+  ~PerFrameEqn();
 
-  };
+  /// Evaluate the per frame equation
+  void evaluate();
+
+};
 
 
 #endif /** !_PER_FRAME_EQN_H */
diff --git a/src/libprojectM/MilkdropPresetFactory/PerPixelEqn.cpp b/src/libprojectM/MilkdropPresetFactory/PerPixelEqn.cpp
index 3f7c7bd..8a0d760 100644
--- a/src/libprojectM/MilkdropPresetFactory/PerPixelEqn.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/PerPixelEqn.cpp
@@ -18,7 +18,6 @@
  * See 'LICENSE.txt' included within this release
  *
  */
-
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -35,47 +34,48 @@
 
 #include "wipemalloc.h"
 #include <cassert>
-/* Evaluates a per pixel equation */
-void PerPixelEqn::evaluate(int mesh_i, int mesh_j) {
 
+
+/* Evaluates a per pixel equation */
+void
+PerPixelEqn::evaluate(int mesh_i, int mesh_j)
+{
   GenExpr * eqn_ptr = 0;
 
 
- eqn_ptr = this->gen_expr;
+  eqn_ptr = this->gen_expr;
 
- float ** param_matrix = (float**)this->param->matrix;
+  float ** param_matrix = (float**)this->param->matrix;
 
- if (param_matrix == 0) {
-	 assert(param->engine_val);
-	 (*(float*)param->engine_val) = eqn_ptr->eval_gen_expr(mesh_i, mesh_j);
+  if (param_matrix == 0) {
+    assert(param->engine_val);
+    (*(float*)param->engine_val) = eqn_ptr->eval_gen_expr(mesh_i, mesh_j);
 
   } else {
 
-  assert(!(eqn_ptr == NULL || param_matrix == NULL));
+    assert(!(eqn_ptr == NULL || param_matrix == NULL));
 
-  param_matrix[mesh_i][mesh_j] = eqn_ptr->eval_gen_expr(mesh_i, mesh_j);
+    param_matrix[mesh_i][mesh_j] = eqn_ptr->eval_gen_expr(mesh_i, mesh_j);
 
-  /* Now that this parameter has been referenced with a per
-     pixel equation, we let the evaluator know by setting
-     this flag */
-  /// @bug review and verify this behavior
-  param->matrix_flag = true;
-  param->flags |= P_FLAG_PER_PIXEL;
+    /* Now that this parameter has been referenced with a per
+    pixel equation, we let the evaluator know by setting
+    this flag */
+    /// @bug review and verify this behavior
+    param->matrix_flag = true;
+    param->flags |= P_FLAG_PER_PIXEL;
   }
 }
 
-PerPixelEqn::PerPixelEqn(int _index, Param * _param, GenExpr * _gen_expr):index(_index), param(_param), gen_expr(_gen_expr) {
-
-	assert(index >= 0);
-	assert(param != 0);
-	assert(gen_expr != 0);
-
+PerPixelEqn::PerPixelEqn(int _index, Param * _param, GenExpr * _gen_expr):index(_index), param(_param), gen_expr(_gen_expr)
+{
+  assert(index >= 0);
+  assert(param != 0);
+  assert(gen_expr != 0);
 }
 
 
 PerPixelEqn::~PerPixelEqn()
 {
-	if (gen_expr)
-		delete (gen_expr);
-
+  if (gen_expr)
+  delete (gen_expr);
 }
diff --git a/src/libprojectM/MilkdropPresetFactory/PerPixelEqn.hpp b/src/libprojectM/MilkdropPresetFactory/PerPixelEqn.hpp
index 9410d76..95ad52e 100644
--- a/src/libprojectM/MilkdropPresetFactory/PerPixelEqn.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/PerPixelEqn.hpp
@@ -25,7 +25,6 @@
  *
  * $Log$
  */
-
 #ifndef _PER_PIXEL_EQN_H
 #define _PER_PIXEL_EQN_H
 
@@ -43,6 +42,7 @@
 #define WARP_OP 9
 #define NUM_OPS 10 /* obviously, this number is dependent on the number of existing per pixel operations */
 
+
 class GenExpr;
 class Param;
 class PerPixelEqn;
@@ -50,18 +50,18 @@
 
 class PerPixelEqn {
 public:
-    int index; /* used for splay tree ordering. */
-    int flags; /* primarily to specify if this variable is user-defined */
-    Param *param;
-    GenExpr *gen_expr;
+  int index; /* used for splay tree ordering. */
+  int flags; /* primarily to specify if this variable is user-defined */
+  Param *param;
+  GenExpr *gen_expr;
 
-    void evalPerPixelEqns( Preset *preset );
-    void evaluate(int mesh_i, int mesh_j);
-    virtual ~PerPixelEqn();
+  void evalPerPixelEqns( Preset *preset );
+  void evaluate(int mesh_i, int mesh_j);
+  virtual ~PerPixelEqn();
 
-    PerPixelEqn(int index, Param * param, GenExpr * gen_expr);
+  PerPixelEqn(int index, Param * param, GenExpr * gen_expr);
 
-  };
+};
 
 
 #endif /** !_PER_PIXEL_EQN_H */
diff --git a/src/libprojectM/MilkdropPresetFactory/PerPointEqn.cpp b/src/libprojectM/MilkdropPresetFactory/PerPointEqn.cpp
index e921916..eef886c 100644
--- a/src/libprojectM/MilkdropPresetFactory/PerPointEqn.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/PerPointEqn.cpp
@@ -18,7 +18,6 @@
  * See 'LICENSE.txt' included within this release
  *
  */
-
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -37,11 +36,12 @@
 #include <iostream>
 #include "wipemalloc.h"
 
-/* Evaluates a per point equation for the current custom wave given by interface_wave ptr */
-void PerPointEqn::evaluate(int i)
-{
 
-  float * param_matrix;
+/* Evaluates a per point equation for the current custom wave given by interface_wave ptr */
+void
+PerPointEqn::evaluate(int i)
+{
+  float   * param_matrix;
   GenExpr * eqn_ptr;
 
   //  samples = CustomWave::interface_wave->samples;
@@ -53,35 +53,30 @@
     assert(param->matrix_flag == false);
     (*(float*)param->engine_val) = eqn_ptr->eval_gen_expr(i,-1);
 
-  
     return;
   }
-
   else
   {
     param_matrix = (float*)param->matrix;
-  
-      // -1 is because per points only use one dimension
-      param_matrix[i] = eqn_ptr->eval_gen_expr(i, -1);
-    
+
+    // -1 is because per points only use one dimension
+    param_matrix[i] = eqn_ptr->eval_gen_expr(i, -1);
+
 
     /* Now that this parameter has been referenced with a per
-       point equation, we let the evaluator know by setting
-       this flag */
+    point equation, we let the evaluator know by setting
+    this flag */
 
     if (!param->matrix_flag)
       param->matrix_flag = true;
-
   }
-
 }
 
-PerPointEqn::PerPointEqn(int _index, Param * _param, GenExpr * _gen_expr, int _samples):
-    index(_index),
+PerPointEqn::PerPointEqn(int _index, Param * _param, GenExpr * _gen_expr, int _samples)
+  : index(_index),
     samples(_samples),
     param(_param),
     gen_expr(_gen_expr)
-
 {}
 
 
diff --git a/src/libprojectM/MilkdropPresetFactory/PerPointEqn.hpp b/src/libprojectM/MilkdropPresetFactory/PerPointEqn.hpp
index 90ba5ca..60b1a43 100644
--- a/src/libprojectM/MilkdropPresetFactory/PerPointEqn.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/PerPointEqn.hpp
@@ -25,10 +25,10 @@
  *
  * $Log$
  */
-
 #ifndef _PER_POINT_EQN_H
 #define _PER_POINT_EQN_H
 
+
 class CustomWave;
 class GenExpr;
 class Param;
@@ -36,14 +36,14 @@
 
 class PerPointEqn {
 public:
-    int index;
-    int samples; // the number of samples to iterate over
-    Param *param;
-    GenExpr * gen_expr;
-    ~PerPointEqn();
-    void evaluate(int i);
-    PerPointEqn( int index, Param *param, GenExpr *gen_expr, int samples);
- };
+  int index;
+  int samples; // the number of samples to iterate over
+  Param *param;
+  GenExpr * gen_expr;
+  ~PerPointEqn();
+  void evaluate(int i);
+  PerPointEqn( int index, Param *param, GenExpr *gen_expr, int samples);
+};
 
 
 //inline void eval_per_point_eqn_helper( void *per_point_eqn ) {
diff --git a/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.cpp b/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.cpp
index 5a4c882..fa0986e 100644
--- a/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.cpp
+++ b/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.cpp
@@ -6,102 +6,103 @@
 #include <cmath>
 #include "Renderer/BeatDetect.hpp"
 
+
 PresetInputs::PresetInputs() : PipelineContext()
 {
 }
 
-void PresetInputs::update(const BeatDetect & music, const PipelineContext & context) {
+void
+PresetInputs::update(const BeatDetect & music, const PipelineContext & context)
+{
 
-    // Reflect new values form the beat detection unit
-    this->bass = music.bass;
-    this->mid = music.mid;
-    this->treb = music.treb;
-    this->bass_att = music.bass_att;
-    this->mid_att = music.mid_att;
-    this->treb_att = music.treb_att;
+  // Reflect new values form the beat detection unit
+  this->bass      = music.bass;
+  this->mid       = music.mid;
+  this->treb      = music.treb;
+  this->bass_att  = music.bass_att;
+  this->mid_att   = music.mid_att;
+  this->treb_att  = music.treb_att;
 
-    // Reflect new values from the pipeline context
-    this->fps = context.fps;
-    this->time = context.time;
+  // Reflect new values from the pipeline context
+  this->fps       = context.fps;
+  this->time      = context.time;
 
-    this->frame = context.frame;
-    this->progress = context.progress;
+  this->frame     = context.frame;
+  this->progress  = context.progress;
 }
 
-void PresetInputs::Initialize ( int gx, int gy )
+void
+PresetInputs::Initialize ( int gx, int gy )
 {
-	int x, y;
+  int x, y;
 
-	this->gx =gx;
-	this->gy= gy;
+  this->gx =gx;
+  this->gy= gy;
 
 
-	/// @bug no clue if this block belongs here
-	// ***
-	progress = 0;
-	frame = 1;
+  /// @bug no clue if this block belongs here
+  // ***
+  progress = 0;
+  frame = 1;
 
-	x_per_pixel = 0;
-	y_per_pixel = 0;
-	rad_per_pixel = 0;
-	ang_per_pixel = 0;
-	// ***
+  x_per_pixel = 0;
+  y_per_pixel = 0;
+  rad_per_pixel = 0;
+  ang_per_pixel = 0;
+  // ***
 
-	this->x_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->x_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->y_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x <gx; x++ )
-	{
-		this->y_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->rad_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->rad_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->theta_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x <gx; x++ )
-	{
-		this->theta_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
+  this->x_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->x_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->y_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x <gx; x++ )
+  {
+    this->y_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->rad_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->rad_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->theta_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x <gx; x++ )
+  {
+    this->theta_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
 
-	this->origtheta= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->origtheta[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->origrad= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->origrad[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->origx= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->origx[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->origy= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->origy[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
+  this->origtheta= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->origtheta[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->origrad= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->origrad[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->origx= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->origx[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->origy= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->origy[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
 
-	for ( x=0;x<gx;x++ )
-	{
-		for ( y=0;y<gy;y++ )
-		{
-			this->origx[x][y]=x/ ( float ) ( gx-1 );
-			this->origy[x][y]=- ( ( y/ ( float ) ( gy-1 ) )-1 );
-			this->origrad[x][y]=hypot ( ( this->origx[x][y]-.5 ) *2, ( this->origy[x][y]-.5 ) *2 ) * .7071067;
-			this->origtheta[x][y]=atan2 ( ( ( this->origy[x][y]-.5 ) *2 ), ( ( this->origx[x][y]-.5 ) *2 ) );
-		}
-	}
-
-
-
+  for ( x=0;x<gx;x++ )
+  {
+    for ( y=0;y<gy;y++ )
+    {
+      this->origx[x][y]=x/ ( float ) ( gx-1 );
+      this->origy[x][y]=- ( ( y/ ( float ) ( gy-1 ) )-1 );
+      this->origrad[x][y]=hypot ( ( this->origx[x][y]-.5 ) *2, ( this->origy[x][y]-.5 ) *2 ) * .7071067;
+      this->origtheta[x][y]=atan2 ( ( ( this->origy[x][y]-.5 ) *2 ), ( ( this->origx[x][y]-.5 ) *2 ) );
+    }
+  }
 }
 
 PresetOutputs::PresetOutputs() : Pipeline()
@@ -109,341 +110,339 @@
 
 PresetOutputs::~PresetOutputs()
 {
-	assert(this->gx > 0);
+  assert(this->gx > 0);
 
-	for ( int x = 0; x < this->gx; x++ )
-	{
-		free(this->sx_mesh[x]);
-		free(this->sy_mesh[x]);
-		free(this->dy_mesh[x]);
-		free(this->dx_mesh[x]);
-		free(this->cy_mesh[x]);
-		free(this->cx_mesh[x]);
+  for ( int x = 0; x < this->gx; x++ )
+  {
+    free (this->sx_mesh[x]);
+    free (this->sy_mesh[x]);
+    free (this->dy_mesh[x]);
+    free (this->dx_mesh[x]);
+    free (this->cy_mesh[x]);
+    free (this->cx_mesh[x]);
 
-		free(this->warp_mesh[x]);
-		free(this->zoom_mesh[x]);
-		free(this->zoomexp_mesh[x]);
-		free(this->rot_mesh[x]);
-		free(this->orig_x[x]);
-		free(this->orig_y[x]);
-		free(this->rad_mesh[x]);
-	}
+    free (this->warp_mesh[x]);
+    free (this->zoom_mesh[x]);
+    free (this->zoomexp_mesh[x]);
+    free (this->rot_mesh[x]);
+    free (this->orig_x[x]);
+    free (this->orig_y[x]);
+    free (this->rad_mesh[x]);
+  }
 
-		free(this->rad_mesh);
-		free(this->sx_mesh);
-		free(this->sy_mesh);
-		free(this->dy_mesh);
-		free(this->dx_mesh);
-		free(this->cy_mesh);
-		free(this->cx_mesh);
-		free(this->warp_mesh);
-		free(this->zoom_mesh);
-		free(this->zoomexp_mesh);
-		free(this->rot_mesh);
-		free(this->orig_x);
-		free(this->orig_y);
+  free (this->rad_mesh);
+  free (this->sx_mesh);
+  free (this->sy_mesh);
+  free (this->dy_mesh);
+  free (this->dx_mesh);
+  free (this->cy_mesh);
+  free (this->cx_mesh);
+  free (this->warp_mesh);
+  free (this->zoom_mesh);
+  free (this->zoomexp_mesh);
+  free (this->rot_mesh);
+  free (this->orig_x);
+  free (this->orig_y);
 
 }
 
-void PresetOutputs::Render(const BeatDetect &music, const PipelineContext &context)
+void
+PresetOutputs::Render(const BeatDetect &music, const PipelineContext &context)
 {
-	PerPixelMath(context);
+  PerPixelMath(context);
 
-	drawables.clear();
+  drawables.clear();
 
-	drawables.push_back(&mv);
+  drawables.push_back(&mv);
 
-	for (PresetOutputs::cshape_container::iterator pos = customShapes.begin();
-			pos != customShapes.end(); ++pos)
-			{
-				if( (*pos)->enabled==1)	drawables.push_back((*pos));
-			}
+  for (PresetOutputs::cshape_container::iterator pos = customShapes.begin();
+       pos != customShapes.end();
+       ++pos)
+  {
+    if( (*pos)->enabled==1) drawables.push_back((*pos));
+  }
 
-	for (PresetOutputs::cwave_container::iterator pos = customWaves.begin();
-			pos != customWaves.end(); ++pos)
-			{
-				if( (*pos)->enabled==1)	drawables.push_back((*pos));
-			}
+  for (PresetOutputs::cwave_container::iterator pos = customWaves.begin();
+       pos != customWaves.end();
+       ++pos)
+  {
+    if( (*pos)->enabled==1) drawables.push_back((*pos));
+  }
 
-    	drawables.push_back(&wave);
-	if(bDarkenCenter==1) drawables.push_back(&darkenCenter);
-	drawables.push_back(&border);
+  drawables.push_back(&wave);
+  if(bDarkenCenter==1) drawables.push_back(&darkenCenter);
+  drawables.push_back(&border);
 
-	compositeDrawables.clear();
-	compositeDrawables.push_back(&videoEcho);
+  compositeDrawables.clear();
+  compositeDrawables.push_back(&videoEcho);
 
-	if (bBrighten==1)
-		compositeDrawables.push_back(&brighten);
+  if (bBrighten==1)
+    compositeDrawables.push_back(&brighten);
 
-	if (bDarken==1)
-		compositeDrawables.push_back(&darken);
+  if (bDarken==1)
+    compositeDrawables.push_back(&darken);
 
-	if (bSolarize==1)
-		compositeDrawables.push_back(&solarize);
+  if (bSolarize==1)
+    compositeDrawables.push_back(&solarize);
 
-	if (bInvert==1)
-		compositeDrawables.push_back(&invert);
+  if (bInvert==1)
+    compositeDrawables.push_back(&invert);
 }
 
 
-void PresetOutputs::PerPixelMath(const PipelineContext &context)
+void
+PresetOutputs::PerPixelMath(const PipelineContext &context)
 {
+  int   x, y;
+  float fZoom2, fZoom2Inv;
 
-	int x, y;
-	float fZoom2, fZoom2Inv;
+  for (x = 0; x < gx; x++)
+  {
+    for (y = 0; y < gy; y++)
+    {
+      fZoom2 = std::pow(this->zoom_mesh[x][y], std::pow(this->zoomexp_mesh[x][y],
+                                                        rad_mesh[x][y] * 2.0f - 1.0f));
+      fZoom2Inv = 1.0f / fZoom2;
+      this->x_mesh[x][y] = this->orig_x[x][y] * 0.5f * fZoom2Inv + 0.5f;
+      this->y_mesh[x][y] = this->orig_y[x][y] * 0.5f * fZoom2Inv + 0.5f;
+    }
+  }
 
-	for (x = 0; x < gx; x++)
-	{
-		for (y = 0; y < gy; y++)
-		{
-			fZoom2 = std::pow(this->zoom_mesh[x][y], std::pow(this->zoomexp_mesh[x][y],
-					rad_mesh[x][y] * 2.0f - 1.0f));
-			fZoom2Inv = 1.0f / fZoom2;
-			this->x_mesh[x][y] = this->orig_x[x][y] * 0.5f * fZoom2Inv + 0.5f;
-			this->y_mesh[x][y] = this->orig_y[x][y] * 0.5f * fZoom2Inv + 0.5f;
-		}
-	}
+  for (x = 0; x < gx; x++)
+  {
+    for (y = 0; y < gy; y++)
+    {
+      this->x_mesh[x][y] = (this->x_mesh[x][y] - this->cx_mesh[x][y])
+                         / this->sx_mesh[x][y] + this->cx_mesh[x][y];
+    }
+  }
 
-	for (x = 0; x < gx; x++)
-	{
-		for (y = 0; y < gy; y++)
-		{
-			this->x_mesh[x][y] = (this->x_mesh[x][y] - this->cx_mesh[x][y])
-					/ this->sx_mesh[x][y] + this->cx_mesh[x][y];
-		}
-	}
+  for (x = 0; x < gx; x++)
+  {
+    for (y = 0; y < gy; y++)
+    {
+      this->y_mesh[x][y] = (this->y_mesh[x][y] - this->cy_mesh[x][y])
+                         / this->sy_mesh[x][y] + this->cy_mesh[x][y];
+    }
+  }
 
-	for (x = 0; x < gx; x++)
-	{
-		for (y = 0; y < gy; y++)
-		{
-			this->y_mesh[x][y] = (this->y_mesh[x][y] - this->cy_mesh[x][y])
-					/ this->sy_mesh[x][y] + this->cy_mesh[x][y];
-		}
-	}
+  float fWarpTime = context.time * this->fWarpAnimSpeed;
+  float fWarpScaleInv = 1.0f / this->fWarpScale;
+  float f[4];
+  f[0] = 11.68f + 4.0f * cosf(fWarpTime * 1.413f + 10);
+  f[1] = 8.77f + 3.0f * cosf(fWarpTime * 1.113f + 7);
+  f[2] = 10.54f + 3.0f * cosf(fWarpTime * 1.233f + 3);
+  f[3] = 11.49f + 4.0f * cosf(fWarpTime * 0.933f + 5);
 
-	float fWarpTime = context.time * this->fWarpAnimSpeed;
-	float fWarpScaleInv = 1.0f / this->fWarpScale;
-	float f[4];
-	f[0] = 11.68f + 4.0f * cosf(fWarpTime * 1.413f + 10);
-	f[1] = 8.77f + 3.0f * cosf(fWarpTime * 1.113f + 7);
-	f[2] = 10.54f + 3.0f * cosf(fWarpTime * 1.233f + 3);
-	f[3] = 11.49f + 4.0f * cosf(fWarpTime * 0.933f + 5);
+  for (x = 0; x < gx; x++)
+  {
+    for (y = 0; y < gy; y++)
+    {
+      this->x_mesh[x][y] += this->warp_mesh[x][y] * 0.0035f * sinf(fWarpTime * 0.333f
+                          + fWarpScaleInv * (this->orig_x[x][y] * f[0] - this->orig_y[x][y] * f[3]));
+      this->y_mesh[x][y] += this->warp_mesh[x][y] * 0.0035f * cosf(fWarpTime * 0.375f
+                          - fWarpScaleInv * (this->orig_x[x][y] * f[2] + this->orig_y[x][y] * f[1]));
+      this->x_mesh[x][y] += this->warp_mesh[x][y] * 0.0035f * cosf(fWarpTime * 0.753f
+                          - fWarpScaleInv * (this->orig_x[x][y] * f[1] - this->orig_y[x][y] * f[2]));
+      this->y_mesh[x][y] += this->warp_mesh[x][y] * 0.0035f * sinf(fWarpTime * 0.825f
+                          + fWarpScaleInv * (this->orig_x[x][y] * f[0] + this->orig_y[x][y] * f[3]));
+    }
+  }
+  for (x = 0; x < gx; x++)
+  {
+    for (y = 0; y < gy; y++)
+    {
+      float u2 = this->x_mesh[x][y] - this->cx_mesh[x][y];
+      float v2 = this->y_mesh[x][y] - this->cy_mesh[x][y];
 
-	for (x = 0; x < gx; x++)
-	{
-		for (y = 0; y < gy; y++)
-		{
-			this->x_mesh[x][y] += this->warp_mesh[x][y] * 0.0035f * sinf(fWarpTime * 0.333f
-					+ fWarpScaleInv * (this->orig_x[x][y] * f[0] - this->orig_y[x][y] * f[3]));
-			this->y_mesh[x][y] += this->warp_mesh[x][y] * 0.0035f * cosf(fWarpTime * 0.375f
-					- fWarpScaleInv * (this->orig_x[x][y] * f[2] + this->orig_y[x][y] * f[1]));
-			this->x_mesh[x][y] += this->warp_mesh[x][y] * 0.0035f * cosf(fWarpTime * 0.753f
-					- fWarpScaleInv * (this->orig_x[x][y] * f[1] - this->orig_y[x][y] * f[2]));
-			this->y_mesh[x][y] += this->warp_mesh[x][y] * 0.0035f * sinf(fWarpTime * 0.825f
-					+ fWarpScaleInv * (this->orig_x[x][y] * f[0] + this->orig_y[x][y] * f[3]));
-		}
-	}
-	for (x = 0; x < gx; x++)
-	{
-		for (y = 0; y < gy; y++)
-		{
-			float u2 = this->x_mesh[x][y] - this->cx_mesh[x][y];
-			float v2 = this->y_mesh[x][y] - this->cy_mesh[x][y];
+      float cos_rot = cosf(this->rot_mesh[x][y]);
+      float sin_rot = sinf(this->rot_mesh[x][y]);
 
-			float cos_rot = cosf(this->rot_mesh[x][y]);
-			float sin_rot = sinf(this->rot_mesh[x][y]);
+      this->x_mesh[x][y] = u2 * cos_rot - v2 * sin_rot + this->cx_mesh[x][y];
+      this->y_mesh[x][y] = u2 * sin_rot + v2 * cos_rot + this->cy_mesh[x][y];
+    }
+  }
 
-			this->x_mesh[x][y] = u2 * cos_rot - v2 * sin_rot + this->cx_mesh[x][y];
-			this->y_mesh[x][y] = u2 * sin_rot + v2 * cos_rot + this->cy_mesh[x][y];
+  for (x = 0; x < gx; x++)
+    for (y = 0; y < gy; y++)
+      this->x_mesh[x][y] -= this->dx_mesh[x][y];
 
-		}
-	}
-
-	for (x = 0; x < gx; x++)
-		for (y = 0; y < gy; y++)
-			this->x_mesh[x][y] -= this->dx_mesh[x][y];
-
-	for (x = 0; x < gx; x++)
-		for (y = 0; y < gy; y++)
-			this->y_mesh[x][y] -= this->dy_mesh[x][y];
-
+  for (x = 0; x < gx; x++)
+    for (y = 0; y < gy; y++)
+      this->y_mesh[x][y] -= this->dy_mesh[x][y];
 }
 
 
-void PresetOutputs::Initialize ( int gx, int gy )
+void
+PresetOutputs::Initialize ( int gx, int gy )
 {
+  assert(gx > 0);
+  this->gx = gx;
+  this->gy= gy;
 
-	assert(gx > 0);
-	this->gx = gx;
-	this->gy= gy;
+  staticPerPixel = true;
+  setStaticPerPixel(gx,gy);
 
-	staticPerPixel = true;
-	setStaticPerPixel(gx,gy);
+  assert(this->gx > 0);
+  int x;
+  this->x_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->x_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->y_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->y_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->sx_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->sx_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->sy_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->sy_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->dx_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->dx_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->dy_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->dy_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->cx_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->cx_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->cy_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->cy_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->zoom_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->zoom_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->zoomexp_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->zoomexp_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->rot_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->rot_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
 
-	assert(this->gx > 0);
-	int x;
-	this->x_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->x_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->y_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->y_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->sx_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->sx_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->sy_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->sy_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->dx_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->dx_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->dy_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->dy_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->cx_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->cx_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->cy_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->cy_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->zoom_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->zoom_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->zoomexp_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->zoomexp_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->rot_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->rot_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
+  this->warp_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->warp_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->rad_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
+  for ( x = 0; x < gx; x++ )
+  {
+    this->rad_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
+  }
+  this->orig_x = (float **) wipemalloc(gx * sizeof(float *));
+  for (x = 0; x < gx; x++)
+  {
+    this->orig_x[x] = (float *) wipemalloc(gy * sizeof(float));
+  }
+  this->orig_y = (float **) wipemalloc(gx * sizeof(float *));
+  for (x = 0; x < gx; x++)
+  {
+    this->orig_y[x] = (float *) wipemalloc(gy * sizeof(float));
+  }
 
-	this->warp_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->warp_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->rad_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) );
-	for ( x = 0; x < gx; x++ )
-	{
-		this->rad_mesh[x] = ( float * ) wipemalloc ( gy * sizeof ( float ) );
-	}
-	this->orig_x = (float **) wipemalloc(gx * sizeof(float *));
-	for (x = 0; x < gx; x++)
-	{
-		this->orig_x[x] = (float *) wipemalloc(gy * sizeof(float));
-	}
-	this->orig_y = (float **) wipemalloc(gx * sizeof(float *));
-	for (x = 0; x < gx; x++)
-	{
-		this->orig_y[x] = (float *) wipemalloc(gy * sizeof(float));
-	}
+  //initialize reference grid values
+  for (x = 0; x < gx; x++)
+  {
+    for (int y = 0; y < gy; y++)
+    {
+      float origx = x / (float) (gx - 1);
+      float origy = -((y / (float) (gy - 1)) - 1);
 
-		//initialize reference grid values
-		for (x = 0; x < gx; x++)
-		{
-			for (int y = 0; y < gy; y++)
-			{
-				float origx = x / (float) (gx - 1);
-				float origy = -((y / (float) (gy - 1)) - 1);
-
-				rad_mesh[x][y]=hypot ( ( origx-.5 ) *2, ( origy-.5 ) *2 ) * .7071067;
-				orig_x[x][y] = (origx - .5) * 2;
-				orig_y[x][y] = (origy - .5) * 2;
-			}
-		}
+      rad_mesh[x][y]=hypot ( ( origx-.5 ) *2, ( origy-.5 ) *2 ) * .7071067;
+      orig_x[x][y] = (origx - .5) * 2;
+      orig_y[x][y] = (origy - .5) * 2;
+    }
+  }
 }
 
 PresetInputs::~PresetInputs()
 {
-	for ( int x = 0; x < this->gx; x++ )
-	{
+  for ( int x = 0; x < this->gx; x++ )
+  {
+    free ( this->origtheta[x] );
+    free ( this->origrad[x] );
+    free ( this->origx[x] );
+    free ( this->origy[x] );
+
+    free ( this->x_mesh[x] );
+    free ( this->y_mesh[x] );
+    free ( this->rad_mesh[x] );
+    free ( this->theta_mesh[x] );
+  }
 
 
-		free ( this->origtheta[x] );
-		free ( this->origrad[x] );
-		free ( this->origx[x] );
-		free ( this->origy[x] );
+  free ( this->origx );
+  free ( this->origy );
+  free ( this->origrad );
+  free ( this->origtheta );
 
-		free ( this->x_mesh[x] );
-		free ( this->y_mesh[x] );
-		free ( this->rad_mesh[x] );
-		free ( this->theta_mesh[x] );
+  free ( this->x_mesh );
+  free ( this->y_mesh );
+  free ( this->rad_mesh );
+  free ( this->theta_mesh );
 
-	}
+  this->origx = NULL;
+  this->origy = NULL;
+  this->origtheta = NULL;
+  this->origrad = NULL;
 
-
-	free ( this->origx );
-	free ( this->origy );
-	free ( this->origrad );
-	free ( this->origtheta );
-
-	free ( this->x_mesh );
-	free ( this->y_mesh );
-	free ( this->rad_mesh );
-	free ( this->theta_mesh );
-
-	this->origx = NULL;
-	this->origy = NULL;
-	this->origtheta = NULL;
-	this->origrad = NULL;
-
-	this->x_mesh = NULL;
-	this->y_mesh = NULL;
-	this->rad_mesh = NULL;
-	this->theta_mesh = NULL;
+  this->x_mesh = NULL;
+  this->y_mesh = NULL;
+  this->rad_mesh = NULL;
+  this->theta_mesh = NULL;
 }
 
 
 void PresetInputs::resetMesh()
 {
-	int x,y;
+  int x,y;
 
-	assert ( x_mesh );
-	assert ( y_mesh );
-	assert ( rad_mesh );
-	assert ( theta_mesh );
+  assert ( x_mesh );
+  assert ( y_mesh );
+  assert ( rad_mesh );
+  assert ( theta_mesh );
 
-	for ( x=0;x<this->gx;x++ )
-	{
-		for ( y=0;y<this->gy;y++ )
-		{
-			x_mesh[x][y]=this->origx[x][y];
-			y_mesh[x][y]=this->origy[x][y];
-			rad_mesh[x][y]=this->origrad[x][y];
-			theta_mesh[x][y]=this->origtheta[x][y];
-		}
-	}
-
+  for ( x=0;x<this->gx;x++ )
+  {
+    for ( y=0;y<this->gy;y++ )
+    {
+      x_mesh[x][y]=this->origx[x][y];
+      y_mesh[x][y]=this->origy[x][y];
+      rad_mesh[x][y]=this->origrad[x][y];
+      theta_mesh[x][y]=this->origtheta[x][y];
+    }
+  }
 }
 
 
 #ifdef USE_MERGE_PRESET_CODE
-void PresetMerger::MergePresets(PresetOutputs & A, PresetOutputs & B, double ratio, int gx, int gy)
+void
+PresetMerger::MergePresets(PresetOutputs & A, PresetOutputs & B, double ratio, int gx, int gy)
 {
 
-double invratio = 1.0 - ratio;
+  double invratio = 1.0 - ratio;
   //Merge Simple Waveforms
   //
   // All the mess is because of Waveform 7, which is two lines.
@@ -453,65 +452,69 @@
   //Merge Custom Shapes and Custom Waves
 
   for (PresetOutputs::cshape_container::iterator pos = A.customShapes.begin();
-	pos != A.customShapes.end(); ++pos)
-    {
-       (*pos)->a *= invratio;
-       (*pos)->a2 *= invratio;
-       (*pos)->border_a *= invratio;
-    }
+       pos != A.customShapes.end();
+       ++pos)
+  {
+    (*pos)->a *= invratio;
+    (*pos)->a2 *= invratio;
+    (*pos)->border_a *= invratio;
+  }
 
   for (PresetOutputs::cshape_container::iterator pos = B.customShapes.begin();
-	pos != B.customShapes.end(); ++pos)
-    {
-       (*pos)->a *= ratio;
-       (*pos)->a2 *= ratio;
-       (*pos)->border_a *= ratio;
+       pos != B.customShapes.end();
+       ++pos)
+  {
+    (*pos)->a *= ratio;
+    (*pos)->a2 *= ratio;
+    (*pos)->border_a *= ratio;
 
-        A.customShapes.push_back(*pos);
+    A.customShapes.push_back(*pos);
+  }
 
-    }
- for (PresetOutputs::cwave_container::iterator pos = A.customWaves.begin();
-	pos != A.customWaves.end(); ++pos)
+  for (PresetOutputs::cwave_container::iterator pos = A.customWaves.begin();
+       pos != A.customWaves.end();
+       ++pos)
+  {
+    (*pos)->a *= invratio;
+    for (int x=0; x <   (*pos)->samples; x++)
     {
-       (*pos)->a *= invratio;
-      for (int x=0; x <   (*pos)->samples; x++)
-	{
-	   (*pos)->a_mesh[x]= (*pos)->a_mesh[x]*invratio;
-	}
+      (*pos)->a_mesh[x]= (*pos)->a_mesh[x]*invratio;
     }
+  }
 
   for (PresetOutputs::cwave_container::iterator pos = B.customWaves.begin();
-	pos != B.customWaves.end(); ++pos)
+       pos != B.customWaves.end();
+       ++pos)
+  {
+    (*pos)->a *= ratio;
+    for (int x=0; x < (*pos)->samples; x++)
     {
-       (*pos)->a *= ratio;
-      for (int x=0; x < (*pos)->samples; x++)
-	{
-	   (*pos)->a_mesh[x]= (*pos)->a_mesh[x]*ratio;
-	}
-       A.customWaves.push_back(*pos);
+      (*pos)->a_mesh[x]= (*pos)->a_mesh[x]*ratio;
     }
+    A.customWaves.push_back(*pos);
+  }
 
 
   //Interpolate Per-Pixel mesh
 
   for (int x=0;x<gx;x++)
+  {
+    for(int y=0;y<gy;y++)
     {
-      for(int y=0;y<gy;y++)
-	{
-	  A.x_mesh[x][y]  = A.x_mesh[x][y]* invratio + B.x_mesh[x][y]*ratio;
-	}
+      A.x_mesh[x][y]  = A.x_mesh[x][y]* invratio + B.x_mesh[x][y]*ratio;
     }
- for (int x=0;x<gx;x++)
+  }
+  for (int x=0;x<gx;x++)
+  {
+    for(int y=0;y<gy;y++)
     {
-      for(int y=0;y<gy;y++)
-	{
-	  A.y_mesh[x][y]  = A.y_mesh[x][y]* invratio + B.y_mesh[x][y]*ratio;
-	}
+      A.y_mesh[x][y]  = A.y_mesh[x][y]* invratio + B.y_mesh[x][y]*ratio;
     }
+  }
 
 
 
- //Interpolate PerFrame floats
+  //Interpolate PerFrame floats
 
   A.screenDecay = A.screenDecay * invratio + B.screenDecay * ratio;
 
@@ -559,17 +562,17 @@
   //Switch bools and discrete values halfway.  Maybe we should do some interesting stuff here.
 
   if (ratio > 0.5)
-    {
-      A.videoEcho.orientation = B.videoEcho.orientation;
-      A.textureWrap = B.textureWrap;
-      A.bDarkenCenter = B.bDarkenCenter;
-      A.bRedBlueStereo = B.bRedBlueStereo;
-      A.bBrighten = B.bBrighten;
-      A.bDarken = B.bDarken;
-      A.bSolarize = B.bSolarize;
-      A.bInvert = B.bInvert;
-      A.bMotionVectorsOn = B.bMotionVectorsOn;
-    }
+  {
+    A.videoEcho.orientation = B.videoEcho.orientation;
+    A.textureWrap = B.textureWrap;
+    A.bDarkenCenter = B.bDarkenCenter;
+    A.bRedBlueStereo = B.bRedBlueStereo;
+    A.bBrighten = B.bBrighten;
+    A.bDarken = B.bDarken;
+    A.bSolarize = B.bSolarize;
+    A.bInvert = B.bInvert;
+    A.bMotionVectorsOn = B.bMotionVectorsOn;
+  }
 
   return;
 }
diff --git a/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.hpp b/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.hpp
index 229879c..9b7a5a4 100644
--- a/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.hpp
+++ b/src/libprojectM/MilkdropPresetFactory/PresetFrameIO.hpp
@@ -1,5 +1,6 @@
 #ifndef PRESET_FRAME_IO_HPP
 #define PRESET_FRAME_IO_HPP
+
 #include <vector>
 #include "Renderer/MilkdropWaveform.hpp"
 #include "Renderer/Pipeline.hpp"
@@ -14,51 +15,51 @@
 class PresetInputs : public PipelineContext {
 
 public:
-    /* PER_PIXEL VARIBLES BEGIN */
+  /* PER_PIXEL VARIBLES BEGIN */
 
-    float x_per_pixel;
-    float y_per_pixel;
-    float rad_per_pixel;
-    float ang_per_pixel;
+  float x_per_pixel;
+  float y_per_pixel;
+  float rad_per_pixel;
+  float ang_per_pixel;
 
-    /* PER_PIXEL VARIBLES END */
+  /* PER_PIXEL VARIBLES END */
 
-    float bass;
-    float mid;
-    float treb;
-    float bass_att;
-    float mid_att;
-    float treb_att;
+  float bass;
+  float mid;
+  float treb;
+  float bass_att;
+  float mid_att;
+  float treb_att;
 
-    /* variables were added in milkdrop 1.04 */
-    int gx, gy;
+  /* variables were added in milkdrop 1.04 */
+  int gx, gy;
 
-    float **x_mesh;
-    float **y_mesh;
-    float **rad_mesh;
-    float **theta_mesh;
+  float **x_mesh;
+  float **y_mesh;
+  float **rad_mesh;
+  float **theta_mesh;
 
-    float **origtheta;  //grid containing interpolated mesh reference values
-    float **origrad;
-    float **origx;  //original mesh
-    float **origy;
+  float **origtheta;  //grid containing interpolated mesh reference values
+  float **origrad;
+  float **origx;  //original mesh
+  float **origy;
 
-    void resetMesh();
+  void resetMesh();
 
-    ~PresetInputs();
-    PresetInputs();
+  ~PresetInputs();
+  PresetInputs();
 
-    /// Initializes this preset inputs given a mesh size.
-    /// \param gx the width of the mesh 
-    /// \param gy the height of the mesh
-    /// \note This must be called before reading values from this class
-    void Initialize(int gx, int gy);
+  /// Initializes this preset inputs given a mesh size.
+  /// \param gx the width of the mesh
+  /// \param gy the height of the mesh
+  /// \note This must be called before reading values from this class
+  void Initialize(int gx, int gy);
 
-    /// Updates this preset inputs with the latest values from the
-    /// the pipeline context and beat detection unit
-    void update (const BeatDetect & music, const PipelineContext & context);
+  /// Updates this preset inputs with the latest values from the
+  /// the pipeline context and beat detection unit
+  void update (const BeatDetect & music, const PipelineContext & context);
 
-    private:
+private:
 };
 
 
@@ -67,77 +68,77 @@
 /// Every preset object needs a reference to one of these.
 class PresetOutputs : public Pipeline {
 public:
-    typedef std::vector<CustomWave*> cwave_container;
-    typedef std::vector<CustomShape*> cshape_container;
+  typedef std::vector<CustomWave*> cwave_container;
+  typedef std::vector<CustomShape*> cshape_container;
 
-    cwave_container customWaves;
-    cshape_container customShapes;
+  cwave_container customWaves;
+  cshape_container customShapes;
 
-    void Initialize(int gx, int gy);
-    PresetOutputs();
-    ~PresetOutputs();
-    virtual void Render(const BeatDetect &music, const PipelineContext &context);
-    void PerPixelMath( const PipelineContext &context);
-    /* PER FRAME VARIABLES BEGIN */
+  void Initialize(int gx, int gy);
+  PresetOutputs();
+  ~PresetOutputs();
+  virtual void Render(const BeatDetect &music, const PipelineContext &context);
+  void PerPixelMath( const PipelineContext &context);
+  /* PER FRAME VARIABLES BEGIN */
 
-    float zoom;
-    float zoomexp;
-    float rot;
-    float warp;
+  float zoom;
+  float zoomexp;
+  float rot;
+  float warp;
 
-    float sx;
-    float sy;
-    float dx;
-    float dy;
-    float cx;
-    float cy;
+  float sx;
+  float sy;
+  float dx;
+  float dy;
+  float cx;
+  float cy;
 
-    VideoEcho videoEcho;
+  VideoEcho videoEcho;
 
-    MilkdropWaveform wave;
-    Border border;
-    MotionVectors mv;
-    DarkenCenter darkenCenter;
+  MilkdropWaveform wave;
+  Border border;
+  MotionVectors mv;
+  DarkenCenter darkenCenter;
 
-    Brighten brighten;
-    Darken darken;
-    Invert invert;
-    Solarize solarize;
+  Brighten brighten;
+  Darken darken;
+  Invert invert;
+  Solarize solarize;
 
 
-    int gy,gx;
-    /* PER_FRAME VARIABLES END */
+  int gy,gx;
+  /* PER_FRAME VARIABLES END */
 
-    float fRating;
-    float fGammaAdj;
+  float fRating;
+  float fGammaAdj;
 
-    bool bDarkenCenter;
-    bool bRedBlueStereo;
-    bool bBrighten;
-    bool bDarken;
-    bool bSolarize;
-    bool bInvert;
-    bool bMotionVectorsOn;
+  bool bDarkenCenter;
+  bool bRedBlueStereo;
+  bool bBrighten;
+  bool bDarken;
+  bool bSolarize;
+  bool bInvert;
+  bool bMotionVectorsOn;
 
-    float fWarpAnimSpeed;
-    float fWarpScale;
-    float fShader;
+  float fWarpAnimSpeed;
+  float fWarpScale;
+  float fShader;
 
-    float **zoom_mesh;
-    float **zoomexp_mesh;
-    float **rot_mesh;
+  float **zoom_mesh;
+  float **zoomexp_mesh;
+  float **rot_mesh;
 
-    float **sx_mesh;
-    float **sy_mesh;
-    float **dx_mesh;
-    float **dy_mesh;
-    float **cx_mesh;
-    float **cy_mesh;
-    float **warp_mesh;
+  float **sx_mesh;
+  float **sy_mesh;
+  float **dx_mesh;
+  float **dy_mesh;
+  float **cx_mesh;
+  float **cy_mesh;
+  float **warp_mesh;
 
-    float **orig_x;  //original mesh
-    float **orig_y;
-    float **rad_mesh;
+  float **orig_x;  //original mesh
+  float **orig_y;
+  float **rad_mesh;
 };
 
 
diff --git a/src/libprojectM/PCM.cpp b/src/libprojectM/PCM.cpp
index 5ce9d9a..03aafe9 100644
--- a/src/libprojectM/PCM.cpp
+++ b/src/libprojectM/PCM.cpp
@@ -1,6 +1,6 @@
 /**
  * projectM -- Milkdrop-esque visualisation SDK
- * Copyright (C)2003-2004 projectM Team
+ * Copyright (C) 2003-2004 projectM Team
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,6 @@
  * Takes sound data from wherever and hands it back out.
  * Returns PCM Data or spectrum data, or the derivative of the PCM data
  */
-
 #include <stdlib.h>
 #include <stdio.h>
 
@@ -33,225 +32,234 @@
 #include "fftsg.h"
 #include "PCM.hpp"
 #include <cassert>
+#include <iostream>
+
 
 int PCM::maxsamples = 2048;
 
-//initPCM(int samples)
+
+//initPCM (int samples)
 //
 //Initializes the PCM buffer to
 // number of samples specified.
-#include <iostream>
-PCM::PCM() {
-    initPCM( 2048 );
 
-    #ifdef DEBUG
-    std::cerr << "[PCM] MAX SAMPLES:" << maxsamples << std::endl;
-    #endif
-  }
+PCM::PCM ()
+{
+  initPCM (2048);
 
-void PCM::initPCM(int samples) {
+#ifdef DEBUG
+  std::cerr << "[PCM] MAX SAMPLES:" << maxsamples << std::endl;
+#endif
+}
+
+void
+PCM::initPCM (int samples)
+{
   int i;
 
-    waveSmoothing = 0;
+  waveSmoothing = 0;
 
   //Allocate memory for PCM data buffer
-    assert(samples == 2048);
-  PCMd = (float **)wipemalloc(2 * sizeof(float *));
-  PCMd[0] = (float *)wipemalloc(samples * sizeof(float));
-  PCMd[1] = (float *)wipemalloc(samples * sizeof(float));
+  assert (samples == 2048);
+  PCMd    = (float **) wipemalloc (2 * sizeof (float *));
+  PCMd[0] = (float *) wipemalloc (samples * sizeof (float));
+  PCMd[1] = (float *) wipemalloc (samples * sizeof (float));
 
   //maxsamples=samples;
-  newsamples=0;
-    numsamples = maxsamples;
+  newsamples = 0;
+  numsamples = maxsamples;
 
   //Initialize buffers to 0
-  for (i=0;i<samples;i++)
-    {
-      PCMd[0][i]=0;
-      PCMd[1][i]=0;
-    }
+  for (i = 0;  i < samples;  i++) {
+    PCMd[0][i] =
+    PCMd[1][i] = 0;
+  }
 
-  start=0;
+  start = 0;
 
   //Allocate FFT workspace
-  w=  (double *)wipemalloc(maxsamples*sizeof(double));
-  ip= (int *)wipemalloc(maxsamples*sizeof(int));
-  ip[0]=0;
+  w = (double *) wipemalloc (maxsamples * sizeof (double));
+  ip = (int *) wipemalloc (maxsamples * sizeof (int));
+  ip[0] = 0;
 
 
-    /** PCM data */
-//    this->maxsamples = 2048;
-//    this->numsamples = 0;
-//    this->pcmdataL = NULL;
-//    this->pcmdataR = NULL;
+  /** PCM data */
+  //    this->maxsamples = 2048;
+  //    this->numsamples = 0;
+  //    this->pcmdataL = NULL;
+  //    this->pcmdataR = NULL;
 
-    /** Allocate PCM data structures */
-    pcmdataL=(float *)wipemalloc(this->maxsamples*sizeof(float));
-    pcmdataR=(float *)wipemalloc(this->maxsamples*sizeof(float));
+  /** Allocate PCM data structures */
+  pcmdataL = (float *) wipemalloc (this->maxsamples * sizeof (float));
+  pcmdataR = (float *) wipemalloc (this->maxsamples * sizeof (float));
 
 }
 
-PCM::~PCM() {
-
-	free(pcmdataL);
-	free(pcmdataR);
-	free(w);
-	free(ip);
-
-	free(PCMd[0]);
-	free(PCMd[1]);
-	free(PCMd);
-
-}
-
-#include <iostream>
-
-void PCM::addPCMfloat(const float *PCMdata, int samples)
+PCM::~PCM ()
 {
-  int i,j;
+  free (pcmdataL);
+  free (pcmdataR);
+  free (w);
+  free (ip);
 
-  for(i=0;i<samples;i++)
-    {
-      j=i+start;
+  free (PCMd[0]);
+  free (PCMd[1]);
+  free (PCMd);
+}
 
-      if (PCMdata[i] != 0 ) {
 
-	PCMd[0][j%maxsamples] = PCMdata[i];
-	PCMd[1][j%maxsamples] = PCMdata[i];
+void
+PCM::addPCMfloat (const float *PCMdata, int samples)
+{
+  int i, j;
 
-      }
-      else
-	{
-	  PCMd[0][j % maxsamples] = 0;
-	  PCMd[1][j % maxsamples] = 0;
-	}
+  for (i = 0;  i < samples;  i++)
+  {
+    j = i + start;
+
+    if (PCMdata[i] != 0 ) {
+      PCMd[0][j % maxsamples] = PCMdata[i];
+      PCMd[1][j % maxsamples] = PCMdata[i];
+    } else {
+      PCMd[0][j % maxsamples] = 0;
+      PCMd[1][j % maxsamples] = 0;
     }
+  }
 
-  start+=samples;
-  start=start%maxsamples;
+  start += samples;
+  start = start % maxsamples;
 
- newsamples+=samples;
- if (newsamples>maxsamples) newsamples=maxsamples;
-  numsamples = getPCMnew(pcmdataR,1,0,waveSmoothing,0,0);
-    getPCMnew(pcmdataL,0,0,waveSmoothing,0,1);
-    getPCM(vdataL,512,0,1,0,0);
-    getPCM(vdataR,512,1,1,0,0);
+  newsamples += samples;
+  if (newsamples > maxsamples)
+    newsamples = maxsamples;
+
+  numsamples = getPCMnew (pcmdataR, 1, 0, waveSmoothing, 0, 0);
+  getPCMnew (pcmdataL, 0, 0, waveSmoothing, 0, 1);
+  getPCM (vdataL, 512, 0, 1, 0, 0);
+  getPCM (vdataR, 512, 1, 1, 0, 0);
 }
 
-void PCM::addPCM16Data(const short* pcm_data, short samples)  {
-   int i, j;
-
-   for (i = 0; i < samples; ++i) {
-      j=i+start;
-      PCMd[0][j % maxsamples]=(pcm_data[i * 2 + 0]/16384.0);
-      PCMd[1][j % maxsamples]=(pcm_data[i * 2 + 1]/16384.0);
-   }
-
-   start = (start + samples) % maxsamples;
-
-   newsamples+=samples;
-   if (newsamples>maxsamples) newsamples=maxsamples;
-     numsamples = getPCMnew(pcmdataR,1,0,waveSmoothing,0,0);
-    getPCMnew(pcmdataL,0,0,waveSmoothing,0,1);
-    getPCM(vdataL,512,0,1,0,0);
-    getPCM(vdataR,512,1,1,0,0);
-}
-
-
-void PCM::addPCM16(short PCMdata[2][512])
+void
+PCM::addPCM16Data (const short* pcm_data, short samples)
 {
-  int i,j;
+  int i, j;
+
+  for (i = 0;  i < samples;  ++i) {
+    j = i + start;
+    PCMd[0][j % maxsamples] = (pcm_data[i * 2 + 0] / 32768.0);
+    PCMd[1][j % maxsamples] = (pcm_data[i * 2 + 1] / 32768.0);
+  }
+
+  start = (start + samples) % maxsamples;
+
+  newsamples += samples;
+  if (newsamples > maxsamples)
+    newsamples = maxsamples;
+
+  numsamples = getPCMnew (pcmdataR, 1, 0, waveSmoothing, 0, 0);
+  getPCMnew (pcmdataL, 0, 0, waveSmoothing, 0, 1);
+  getPCM (vdataL, 512, 0, 1, 0, 0);
+  getPCM (vdataR, 512, 1, 1, 0, 0);
+}
+
+
+void
+PCM::addPCM16 (short PCMdata[2][512])
+{
+  int i, j;
   int samples=512;
 
-	 for(i=0;i<samples;i++)
-	   {
-	     j=i+start;
-         if ( PCMdata[0][i] != 0 && PCMdata[1][i] != 0 ) {
-	         PCMd[0][j%maxsamples]=(PCMdata[0][i]/16384.0);
-	         PCMd[1][j%maxsamples]=(PCMdata[1][i]/16384.0);
-          } else {
-             PCMd[0][j % maxsamples] = (float)0;
-             PCMd[1][j % maxsamples] = (float)0;
-          }
-	   }
+  for (i = 0;  i < samples; i++) {
+    j = i + start;
+    if (PCMdata[0][i] != 0  &&  PCMdata[1][i] != 0) {
+      PCMd[0][j % maxsamples] = (PCMdata[0][i] / 32768.0);
+      PCMd[1][j % maxsamples] = (PCMdata[1][i] / 32768.0);
+    } else {
+      PCMd[0][j % maxsamples] = (float) 0;
+      PCMd[1][j % maxsamples] = (float) 0;
+    }
+  }
 
-	 // printf("Added %d samples %d %d %f\n",samples,start,(start+samples)%maxsamples,PCM[0][start+10]);
+  // printf ("Added %d samples %d %d %f\n", samples, start,(start+samples)%maxsamples, PCM[0][start+10]);
 
- start+=samples;
- start=start%maxsamples;
+  start += samples;
+  start = start % maxsamples;
 
- newsamples+=samples;
- if (newsamples>maxsamples) newsamples=maxsamples;
+  newsamples += samples;
+  if (newsamples > maxsamples)
+    newsamples = maxsamples;
 
-    numsamples = getPCMnew(pcmdataR,1,0,waveSmoothing,0,0);
-    getPCMnew(pcmdataL,0,0,waveSmoothing,0,1);
-    getPCM(vdataL,512,0,1,0,0);
-    getPCM(vdataR,512,1,1,0,0);
+  numsamples = getPCMnew (pcmdataR, 1, 0, waveSmoothing, 0, 0);
+  getPCMnew (pcmdataL, 0, 0, waveSmoothing, 0, 1);
+  getPCM (vdataL, 512, 0, 1, 0, 0);
+  getPCM (vdataR, 512, 1, 1, 0, 0);
 }
 
 
-void PCM::addPCM8( unsigned char PCMdata[2][1024])
+void
+PCM::addPCM8 (unsigned char PCMdata[2][1024])
 {
-  int i,j;
-  int samples=1024;
+  int i, j;
+  int samples = 1024;
+
+  for (i = 0;  i < samples;  i++) {
+    j = i + start;
+    if (PCMdata[0][i] != 0  &&  PCMdata[1][i] != 0) {
+      PCMd[0][j % maxsamples] = ((float) (PCMdata[0][i] - 128.0) / 64);
+      PCMd[1][j % maxsamples] = ((float) (PCMdata[1][i] - 128.0) / 64);
+    } else {
+      PCMd[0][j % maxsamples] = 0;
+      PCMd[1][j % maxsamples] = 0;
+    }
+  }
 
 
-	 for(i=0;i<samples;i++)
-	   {
-	     j=i+start;
-         if ( PCMdata[0][i] != 0 && PCMdata[1][i] != 0 ) {
-	         PCMd[0][j%maxsamples]=( (float)( PCMdata[0][i] - 128.0 ) / 64 );
-	         PCMd[1][j%maxsamples]=( (float)( PCMdata[1][i] - 128.0 ) / 64 );
-          } else {
-             PCMd[0][j % maxsamples] = 0;
-             PCMd[1][j % maxsamples] = 0;
-          }
-	   }
+  // printf ("Added %d samples %d %d %f\n", samples, start,(start+samples)%maxsamples, PCM[0][start+10]);
 
+  start += samples;
+  start = start % maxsamples;
 
-	 // printf("Added %d samples %d %d %f\n",samples,start,(start+samples)%maxsamples,PCM[0][start+10]);
+  newsamples += samples;
+  if (newsamples > maxsamples)
+    newsamples = maxsamples;
 
- start+=samples;
- start=start%maxsamples;
-
- newsamples+=samples;
- if (newsamples>maxsamples) newsamples=maxsamples;
-    numsamples = getPCMnew(pcmdataR,1,0,waveSmoothing,0,0);
-    getPCMnew(pcmdataL,0,0,waveSmoothing,0,1);
-    getPCM(vdataL,512,0,1,0,0);
-    getPCM(vdataR,512,1,1,0,0);
+  numsamples = getPCMnew (pcmdataR, 1, 0, waveSmoothing, 0, 0);
+  getPCMnew (pcmdataL, 0, 0, waveSmoothing, 0, 1);
+  getPCM (vdataL, 512, 0, 1, 0, 0);
+  getPCM (vdataR, 512, 1, 1, 0, 0);
 }
 
-void PCM::addPCM8_512( const unsigned char PCMdata[2][512])
+void
+PCM::addPCM8_512 (const unsigned char PCMdata[2][512])
 {
-  int i,j;
-  int samples=512;
+  int i, j;
+  int samples = 512;
+
+  for (i = 0;  i < samples;  i++) {
+    j = i + start;
+    if (PCMdata[0][i] != 0  &&  PCMdata[1][i] != 0) {
+      PCMd[0][j % maxsamples] = ((float) (PCMdata[0][i] - 128.0) / 64);
+      PCMd[1][j % maxsamples] = ((float) (PCMdata[1][i] - 128.0) / 64);
+    } else {
+      PCMd[0][j % maxsamples] = 0;
+      PCMd[1][j % maxsamples] = 0;
+    }
+  }
 
 
-	 for(i=0;i<samples;i++)
-	   {
-	     j=i+start;
-         if ( PCMdata[0][i] != 0 && PCMdata[1][i] != 0 ) {
-	         PCMd[0][j%maxsamples]=( (float)( PCMdata[0][i] - 128.0 ) / 64 );
-	         PCMd[1][j%maxsamples]=( (float)( PCMdata[1][i] - 128.0 ) / 64 );
-          } else {
-             PCMd[0][j % maxsamples] = 0;
-             PCMd[1][j % maxsamples] = 0;
-          }
-	   }
+  // printf ("Added %d samples %d %d %f\n", samples, start,(start+samples)%maxsamples, PCM[0][start+10]);
 
+  start += samples;
+  start = start % maxsamples;
 
-	 // printf("Added %d samples %d %d %f\n",samples,start,(start+samples)%maxsamples,PCM[0][start+10]);
+  newsamples += samples;
+  if (newsamples > maxsamples)
+    newsamples = maxsamples;
 
- start+=samples;
- start=start%maxsamples;
-
- newsamples+=samples;
- if (newsamples>maxsamples) newsamples=maxsamples;
-    numsamples = getPCMnew(pcmdataR,1,0,waveSmoothing,0,0);
-    getPCMnew(pcmdataL,0,0,waveSmoothing,0,1);
-    getPCM(vdataL,512,0,1,0,0);
-    getPCM(vdataR,512,1,1,0,0);
+  numsamples = getPCMnew (pcmdataR, 1, 0, waveSmoothing, 0, 0);
+  getPCMnew (pcmdataL, 0, 0, waveSmoothing, 0, 1);
+  getPCM (vdataL, 512, 0, 1, 0, 0);
+  getPCM (vdataR, 512, 1, 1, 0, 0);
 }
 
 
@@ -264,46 +272,54 @@
 
 //returned values are normalized from -1 to 1
 
-void PCM::getPCM(float *PCMdata, int samples, int channel, int freq, float smoothing, int derive)
+void
+PCM::getPCM (
+float *PCMdata,
+int   samples,
+int   channel,
+int   freq,
+float smoothing,
+int   derive
+)
 {
-   int i,index;
+  int i, index;
 
-   index=start-1;
+  index = start - 1;
 
-   if (index<0) index=maxsamples+index;
+  if (index < 0)
+    index = maxsamples + index;
 
-   PCMdata[0]=PCMd[channel][index];
+  PCMdata[0] = PCMd[channel][index];
 
-   for(i=1;i<samples;i++)
-     {
-       index=start-1-i;
-       if (index<0) index=maxsamples+index;
+  for (i = 1;  i < samples;  i++) {
+    index = start - 1 - i;
+    if (index < 0)
+      index = maxsamples + index;
 
-       PCMdata[i]=(1-smoothing)*PCMd[channel][index]+smoothing*PCMdata[i-1];
-     }
+    PCMdata[i] = (1 - smoothing) * PCMd[channel][index]
+               + smoothing * PCMdata[i - 1];
+  }
 
-   //return derivative of PCM data
-   if(derive)
-     {
-       for(i=0;i<samples-1;i++)
-	 {
-	   PCMdata[i]=PCMdata[i]-PCMdata[i+1];
-	 }
-       PCMdata[samples-1]=0;
-     }
+  //return derivative of PCM data
+  if (derive) {
+    for (i = 0;  i < samples - 1;  i++) {
+      PCMdata[i] = PCMdata[i] - PCMdata[i + 1];
+    }
+    PCMdata[samples-1] = 0;
+  }
 
-   //return frequency data instead of PCM (perform FFT)
+  //return frequency data instead of PCM (perform FFT)
 
-   if (freq)
+  if (freq) {
+    double temppcm[1024];
 
-     {
-       double temppcm[1024];
-       for (int i=0;i<samples;i++)
-	 {temppcm[i]=(double)PCMdata[i];}
-       rdft(samples, 1, temppcm, ip, w);
-       for (int j=0;j<samples;j++)
-	 {PCMdata[j]=(float)temppcm[j];}
-     }
+    for (int i = 0;  i < samples;  i++)
+      {temppcm[i] = (double) PCMdata[i];}
+
+    rdft (samples, 1, temppcm, ip, w);
+    for (int j = 0;  j < samples;  j++)
+      {PCMdata[j] = (float) temppcm[j];}
+  }
 }
 
 //getPCMnew
@@ -311,49 +327,59 @@
 //Like getPCM except it returns all new samples in the buffer
 //the actual return value is the number of samples, up to maxsamples.
 //the passed pointer, PCMData, must bee able to hold up to maxsamples
-
-int PCM::getPCMnew(float *PCMdata, int channel, int freq, float smoothing, int derive, int reset)
+//
+int
+PCM::getPCMnew (
+float *PCMdata,
+int   channel,
+int   freq,
+float smoothing,
+int   derive,
+int   reset
+)
 {
-   int i,index;
+  int i, index;
 
-   index=start-1;
+  index = start - 1;
 
-   if (index<0) index=maxsamples+index;
+  if (index < 0)
+    index = maxsamples + index;
 
-   PCMdata[0]=PCMd[channel][index];
-   for(i=1;i<newsamples;i++)
-     {
-       index=start-1-i;
-       if (index<0) index=maxsamples+index;
+  PCMdata[0] = PCMd[channel][index];
+  for (i = 1;  i < newsamples;  i++) {
+    index = start - 1 - i;
+    if (index < 0)
+      index = maxsamples + index;
 
-       PCMdata[i]=(1-smoothing)*PCMd[channel][index]+smoothing*PCMdata[i-1];
-     }
+    PCMdata[i] = (1 - smoothing) * PCMd[channel][index]
+              + smoothing * PCMdata[i-1];
+  }
 
-   //return derivative of PCM data
-   if(derive)
-     {
-       for(i=0;i<newsamples-1;i++)
-	 {
-	   PCMdata[i]=PCMdata[i]-PCMdata[i+1];
-	 }
-       PCMdata[newsamples-1]=0;
-     }
+  //return derivative of PCM data
+  if (derive) {
+    for (i = 0;  i < newsamples - 1;  i++) {
+      PCMdata[i] = PCMdata[i] - PCMdata[i + 1];
+    }
+    PCMdata[newsamples-1] = 0;
+  }
 
-   //return frequency data instead of PCM (perform FFT)
-   //   if (freq) rdft(samples, 1, PCMdata, ip, w);
-   i=newsamples;
-   if (reset)  newsamples=0;
+  //return frequency data instead of PCM (perform FFT)
+  //   if (freq) rdft (samples, 1, PCMdata, ip, w);
+  i = newsamples;
+  if (reset)  newsamples = 0;
 
-   return i;
+  return i;
 }
 
 //Free stuff
-void PCM::freePCM() {
-  free(PCMd[0]);
-  free(PCMd[1]);
-  free(PCMd);
-  free(ip);
-  free(w);
+void
+PCM::freePCM ()
+{
+  free (PCMd[0]);
+  free (PCMd[1]);
+  free (PCMd);
+  free (ip);
+  free (w);
 
   PCMd = NULL;
   ip = NULL;
diff --git a/src/libprojectM/PCM.hpp b/src/libprojectM/PCM.hpp
index 5888e84..92330a6 100644
--- a/src/libprojectM/PCM.hpp
+++ b/src/libprojectM/PCM.hpp
@@ -29,46 +29,47 @@
 #ifndef _PCM_H
 #define _PCM_H
 
+
 #include "dlldefs.h"
 
+
 class 
 #ifdef WIN32 
 DLLEXPORT 
 #endif 
 PCM {
 public:
-    float **PCMd;
-    int start;
+  float   **PCMd;
+  int     start;
 
-    /** Use wave smoothing */
-    float waveSmoothing;
+  /** Use wave smoothing */
+  float   waveSmoothing;
 
-    int *ip;
-    double *w;
-    int newsamples;
+  int     *ip;
+  double  *w;
+  int     newsamples;
 
-    int numsamples; //size of new PCM info
-    float *pcmdataL;     //holder for most recent pcm data
-    float *pcmdataR;     //holder for most recent pcm data
+  int     numsamples; //size of new PCM info
+  float   *pcmdataL;     //holder for most recent pcm data
+  float   *pcmdataR;     //holder for most recent pcm data
 
-    /** PCM data */
-    float vdataL[512];  //holders for FFT data (spectrum)
-    float vdataR[512];
+  /** PCM data */
+  float   vdataL[512];  //holders for FFT data (spectrum)
+  float   vdataR[512];
 
-    static int maxsamples;
-    PCM();
-    ~PCM();
-    void initPCM(int maxsamples);
-    void addPCMfloat(const float *PCMdata, int samples);
-    void addPCM16(short [2][512]);
-    void addPCM16Data(const short* pcm_data, short samples);
-    void addPCM8( unsigned char [2][1024]);
-	void addPCM8_512( const unsigned char [2][512]);
-    void getPCM(float *data, int samples, int channel, int freq, float smoothing, int derive);
-    void freePCM();
-    int getPCMnew(float *PCMdata, int channel, int freq, float smoothing, int derive,int reset);
+  static int  maxsamples;
 
-
-  };
+        PCM();
+        ~PCM();
+  void  initPCM (int maxsamples);
+  void  addPCMfloat (const float *PCMdata, int samples);
+  void  addPCM16 (short [2][512]);
+  void  addPCM16Data (const short* pcm_data, short samples);
+  void  addPCM8 (unsigned char [2][1024]);
+  void  addPCM8_512 (const unsigned char [2][512]);
+  void  getPCM (float *data, int samples, int channel, int freq, float smoothing, int derive);
+  void  freePCM ();
+  int   getPCMnew (float *PCMdata, int channel, int freq, float smoothing, int derive,int reset);
+};
 
 #endif /** !_PCM_H */
diff --git a/src/libprojectM/PipelineMerger.cpp b/src/libprojectM/PipelineMerger.cpp
index 56640c9..ffb7be2 100644
--- a/src/libprojectM/PipelineMerger.cpp
+++ b/src/libprojectM/PipelineMerger.cpp
@@ -2,122 +2,134 @@
 #include "RenderItemMatcher.hpp"
 #include "RenderItemMergeFunction.hpp"
 
+
+/*  FIXME: Use math.h constants.  */
 const double PipelineMerger::e(2.71828182845904523536);
 const double PipelineMerger::s(0.5);
 
-void PipelineMerger::mergePipelines(const Pipeline & a, const Pipeline & b, Pipeline & out, RenderItemMatcher::MatchResults & results, RenderItemMergeFunction & mergeFunction, float ratio)
 
+void
+PipelineMerger::mergePipelines (
+const Pipeline                  &a,
+const Pipeline                  &b,
+Pipeline                        &out,
+RenderItemMatcher::MatchResults &results,
+RenderItemMergeFunction         &mergeFunction,
+float                           ratio
+)
 {
+  const double x = (ratio - 0.5) * 20;
+  const double sigmoid = 1.0 / (1.0 + e - s * x);
+  const double invratio = 1.0 - ratio;
 
-	const double x = ( ratio - 0.5 ) * 20;
-	const double sigmoid = 1.0 / ( 1.0 + e - s * x );
-	const double invratio = 1.0 - ratio;
+  out.textureWrap = (ratio < 0.5) ? a.textureWrap : b.textureWrap;
 
-	out.textureWrap = ( ratio < 0.5 ) ? a.textureWrap : b.textureWrap;
+  out.screenDecay = lerp (b.screenDecay, a.screenDecay, ratio);
 
-	out.screenDecay = lerp ( b.screenDecay, a.screenDecay, ratio );
+  out.drawables.clear();
+  out.compositeDrawables.clear();
 
-	out.drawables.clear();
-	out.compositeDrawables.clear();
+  for (std::vector<RenderItem*>::const_iterator pos = a.drawables.begin();
+       pos != a.drawables.end();
+       ++pos)
+  {
+    (*pos)->masterAlpha = invratio;
+    out.drawables.push_back (*pos);
+  }
 
-	for ( std::vector<RenderItem*>::const_iterator pos = a.drawables.begin();
-	        pos != a.drawables.end(); ++pos )
-	{
-		( *pos )->masterAlpha = invratio;
-		out.drawables.push_back ( *pos );
-	}
+  for (std::vector<RenderItem*>::const_iterator pos = b.drawables.begin();
+       pos != b.drawables.end();
+       ++pos)
+  {
+    (*pos)->masterAlpha = ratio;
+    out.drawables.push_back (*pos);
+  }
 
-	for ( std::vector<RenderItem*>::const_iterator pos = b.drawables.begin();
-	        pos != b.drawables.end();++pos )
-	{
-		( *pos )->masterAlpha = ratio;
-		out.drawables.push_back ( *pos );
-	}
+  if (ratio < 0.5) {
+    const double local_ratio = (invratio - 0.5) * 2;
 
-    if(ratio < 0.5)
+    for (std::vector<RenderItem*>::const_iterator pos = a.compositeDrawables.begin();
+         pos != a.compositeDrawables.end();
+         ++pos)
     {
-        const double local_ratio = (invratio - 0.5) * 2;
-
-        for (std::vector<RenderItem*>::const_iterator pos = a.compositeDrawables.begin();
-        pos != a.compositeDrawables.end(); ++pos)
-        {
-            (*pos)->masterAlpha = local_ratio;
-            out.compositeDrawables.push_back(*pos);
-        }
+      (*pos)->masterAlpha = local_ratio;
+      out.compositeDrawables.push_back (*pos);
     }
-    else
+  } else {
+    const double local_ratio = (ratio - 0.5) * 2;
+
+    for (std::vector<RenderItem*>::const_iterator pos = b.compositeDrawables.begin();
+         pos != b.compositeDrawables.end();
+         ++pos)
     {
-        const double local_ratio = (ratio - 0.5) * 2;
-
-        for (std::vector<RenderItem*>::const_iterator pos = b.compositeDrawables.begin();
-        pos != b.compositeDrawables.end();++pos)
-        {
-            (*pos)->masterAlpha = local_ratio;
-            out.compositeDrawables.push_back(*pos);
-        }
+      (*pos)->masterAlpha = local_ratio;
+      out.compositeDrawables.push_back (*pos);
     }
+  }
 
-	/*
-	for (RenderItemMatchList::iterator pos = results.matches.begin(); pos != results.matches.end(); ++pos) {
+  /*
+  for (RenderItemMatchList::iterator pos = results.matches.begin();
+       pos != results.matches.end();
+       ++pos)
+  {
+    RenderItem * itemA = pos->first;
+    RenderItem * itemB = pos->second;
 
-		RenderItem * itemA = pos->first;
-		RenderItem * itemB = pos->second;
+    RenderItem * itemC = mergeFunction(itemA, itemB, ratio);
 
-		RenderItem * itemC = mergeFunction(itemA, itemB, ratio);
-
-		if (itemC == 0) {
-			itemA->masterAlpha = ratio;
-	        	out.drawables.push_back(itemA);
-			itemB->masterAlpha = invratio;
-	        	out.drawables.push_back(itemB);
-		} else
-			out.drawables.push_back(itemC);
-
-	}
+    if (itemC == 0) {
+      itemA->masterAlpha = ratio;
+      out.drawables.push_back (itemA);
+      itemB->masterAlpha = invratio;
+      out.drawables.push_back (itemB);
+    } else
+      out.drawables.push_back (itemC);
+  }
 
 
-	for (std::vector<RenderItem*>::const_iterator pos = results.unmatchedLeft.begin();
-		pos != results.unmatchedLeft.end(); ++pos)
-	    {
-	       (*pos)->masterAlpha = invratio;
-	       out.drawables.push_back(*pos);
-	    }
+  for (std::vector<RenderItem*>::const_iterator pos = results.unmatchedLeft.begin();
+       pos != results.unmatchedLeft.end();
+       ++pos)
+  {
+    (*pos)->masterAlpha = invratio;
+    out.drawables.push_back (*pos);
+  }
 
-	for (std::vector<RenderItem*>::const_iterator pos = results.unmatchedRight.begin();
-		pos != results.unmatchedRight.end(); ++pos)
-		{
-		  (*pos)->masterAlpha = ratio;
-		   out.drawables.push_back(*pos);
-		}
-	*/
+  for (std::vector<RenderItem*>::const_iterator pos = results.unmatchedRight.begin();
+       pos != results.unmatchedRight.end();
+       ++pos)
+  {
+    (*pos)->masterAlpha = ratio;
+    out.drawables.push_back (*pos);
+  }
+  */
 
-	if (a.staticPerPixel && b.staticPerPixel)
-	{
-		out.staticPerPixel = true;
-		 for (int x=0;x<a.gx;x++)
-		    {
-		      for(int y=0;y<a.gy;y++)
-			{
-			  out.x_mesh[x][y]  = a.x_mesh[x][y]* invratio + b.x_mesh[x][y]*ratio;
-			}
-		    }
-		 for (int x=0;x<a.gx;x++)
-		    {
-		      for(int y=0;y<a.gy;y++)
-			{
-			  out.y_mesh[x][y]  = a.y_mesh[x][y]* invratio + b.y_mesh[x][y]*ratio;
-			}
-		    }
-	}
-
-    if(ratio < 0.5)
+  if (a.staticPerPixel  &&  b.staticPerPixel) {
+    out.staticPerPixel = true;
+    for (int x = 0;  x < a.gx;  x++)
     {
-	out.compositeShader = a.compositeShader;
-	out.warpShader = a.warpShader;
+      for (int y = 0;  y < a.gy;  y++)
+      {
+        out.x_mesh[x][y]  = a.x_mesh[x][y] * invratio + b.x_mesh[x][y] * ratio;
+      }
     }
-    else
+    for (int x = 0;  x < a.gx;  x++)
     {
-      out.compositeShader = b.compositeShader;
-      out.warpShader = b.warpShader;
+      for (int y = 0;  y < a.gy;  y++)
+      {
+        out.y_mesh[x][y]  = a.y_mesh[x][y] * invratio + b.y_mesh[x][y] * ratio;
+      }
     }
+  }
+
+  if (ratio < 0.5)
+  {
+    out.compositeShader = a.compositeShader;
+    out.warpShader = a.warpShader;
+  }
+  else
+  {
+    out.compositeShader = b.compositeShader;
+    out.warpShader = b.warpShader;
+  }
 }
diff --git a/src/libprojectM/PipelineMerger.hpp b/src/libprojectM/PipelineMerger.hpp
index a0bba91..5d37bae 100644
--- a/src/libprojectM/PipelineMerger.hpp
+++ b/src/libprojectM/PipelineMerger.hpp
@@ -1,28 +1,31 @@
 #ifndef PRESET_MERGE_HPP
 #define PRESET_MERGE_HPP
+
 #include "Preset.hpp"
 #include "Pipeline.hpp"
 #include "RenderItemMatcher.hpp"
 #include "RenderItemMergeFunction.hpp"
 
+
 class PipelineMerger
 {
- template <class T> inline static T lerp(T a, T b, float ratio)
-{
-  return a * ratio + b * (1 - ratio);
-}
+  template <class T> inline static T lerp(T a, T b, float ratio)
+  {
+    return a * ratio + b * (1 - ratio);
+  }
 
 public:
-    
-  static void mergePipelines(const Pipeline &a,  const Pipeline &b, Pipeline &out, 
-	RenderItemMatcher::MatchResults & matching, RenderItemMergeFunction & merger, float ratio);
 
-private :
+  static void mergePipelines(const Pipeline &a,  const Pipeline &b, Pipeline &out,
+                             RenderItemMatcher::MatchResults & matching,
+                             RenderItemMergeFunction & merger, float ratio);
 
-static const double s;
-static const double e;
+private:
+
+  static const double s;
+  static const double e;
 
 };
 
 
-#endif
+#endif  /*  PRESET_MERGE_HPP  */
diff --git a/src/libprojectM/Preset.cpp b/src/libprojectM/Preset.cpp
index 84e823a..91175d8 100644
--- a/src/libprojectM/Preset.cpp
+++ b/src/libprojectM/Preset.cpp
@@ -7,6 +7,7 @@
 
 #include "Preset.hpp"
 
+
 Preset::~Preset() {}
 
 Preset::Preset(const std::string & presetName, const std::string & presetAuthor):
@@ -19,5 +20,3 @@
 void Preset::setAuthor(const std::string & value) { _author = value; }
 
 const std::string & Preset::author() const { return _author; }
-
-
diff --git a/src/libprojectM/Preset.hpp b/src/libprojectM/Preset.hpp
index 4171e97..53ede8e 100644
--- a/src/libprojectM/Preset.hpp
+++ b/src/libprojectM/Preset.hpp
@@ -8,31 +8,32 @@
 #ifndef PRESET_HPP_
 #define PRESET_HPP_
 
+
 #include <string>
 
 #include "Renderer/BeatDetect.hpp"
 #include "Renderer/Pipeline.hpp"
 #include "Renderer/PipelineContext.hpp"
 
+
 class Preset {
 public:
+                      Preset(const std::string & name = std::string(),
+                             const std::string & author = std::string());
+  virtual             ~Preset();
 
-	
-	Preset(const std::string & name=std::string(), const std::string & author = std::string());
-	virtual ~Preset();
+  void                setName(const std::string & value);
+  const std::string & name() const;
 
-	void setName(const std::string & value);
-	const std::string & name() const;
+  void                setAuthor(const std::string & value);
+  const std::string & author() const;
 
-	void setAuthor(const std::string & value);
-	const std::string & author() const;
-
-	virtual Pipeline & pipeline() = 0;
-	virtual void Render(const BeatDetect &music, const PipelineContext &context) = 0;
+  virtual Pipeline &  pipeline() = 0;
+  virtual void        Render(const BeatDetect &music, const PipelineContext &context) = 0;
 
 private:
-	std::string _name;
-	std::string _author;
+  std::string _name;
+  std::string _author;
 };
 
 #endif /* PRESET_HPP_ */
diff --git a/src/libprojectM/PresetChooser.cpp b/src/libprojectM/PresetChooser.cpp
index b239759..253b2d9 100644
--- a/src/libprojectM/PresetChooser.cpp
+++ b/src/libprojectM/PresetChooser.cpp
@@ -11,4 +11,3 @@
 //
 
 #include "PresetChooser.hpp"
-
diff --git a/src/libprojectM/PresetChooser.hpp b/src/libprojectM/PresetChooser.hpp
index ab88b2a..8b645fb 100644
--- a/src/libprojectM/PresetChooser.hpp
+++ b/src/libprojectM/PresetChooser.hpp
@@ -8,46 +8,48 @@
 #include <cassert>
 #include <memory>
 #include <iostream>
+
+
 class PresetChooser;
 
 ///  A simple iterator class to traverse back and forth a preset directory
 class PresetIterator {
 
 public:
-    PresetIterator()  {}
+  PresetIterator()  {}
 
-    /// Instantiate a preset iterator at the given starting position
-    PresetIterator(std::size_t start);
+  /// Instantiate a preset iterator at the given starting position
+  PresetIterator(std::size_t start);
 
-    /// Move iterator forward
-    void operator++();
+  /// Move iterator forward
+  void        operator++();
 
-    /// Move iterator backword
-    void operator--() ;
+  /// Move iterator backword
+  void        operator--() ;
 
-    /// Not equal comparator
-    bool operator !=(const PresetIterator & presetPos) const ;
+  /// Not equal comparator
+  bool        operator !=(const PresetIterator & presetPos) const ;
 
-    /// Equality comparator
-    bool operator ==(const PresetIterator & presetPos) const ;
+  /// Equality comparator
+  bool        operator ==(const PresetIterator & presetPos) const ;
 
-    /// Returns an integer value representing the iterator position
-    /// @bug might become internal
-    /// \brief Returns the indexing value used by the current iterator.
-    std::size_t operator*() const;
+  /// Returns an integer value representing the iterator position
+  /// @bug might become internal
+  /// \brief Returns the indexing value used by the current iterator.
+  std::size_t operator*() const;
 
-    ///  Allocate a new preset given this iterator's associated preset name
-    /// \param presetInputs the preset inputs to associate with the preset upon construction
-    /// \param presetOutputs the preset outputs to associate with the preset upon construction
-    /// \returns an autopointer of the newly allocated preset
-    std::auto_ptr<Preset> allocate();
+  ///  Allocate a new preset given this iterator's associated preset name
+  /// \param presetInputs the preset inputs to associate with the preset upon construction
+  /// \param presetOutputs the preset outputs to associate with the preset upon construction
+  /// \returns an autopointer of the newly allocated preset
+  std::auto_ptr<Preset> allocate();
 
-    ///  Set the chooser asocciated with this iterator
-    void setChooser(const PresetChooser & chooser);
+  ///  Set the chooser asocciated with this iterator
+  void setChooser(const PresetChooser & chooser);
 
 private:
-    std::size_t _currentIndex;
-    const PresetChooser * _presetChooser;
+  std::size_t _currentIndex;
+  const PresetChooser * _presetChooser;
 
 };
 
@@ -55,187 +57,217 @@
 class PresetChooser {
 
 public:
-    typedef PresetIterator iterator;
+  typedef PresetIterator iterator;
 
-    /// Initializes a chooser with an established preset loader.
-    /// \param presetLoader an initialized preset loader to choose presets from
-    /// \note The preset loader is refreshed via events or otherwise outside this class's scope
-    PresetChooser(const PresetLoader & presetLoader, bool 	softCutRatingsEnabled);
+  /// Initializes a chooser with an established preset loader.
+  /// \param presetLoader an initialized preset loader to choose presets from
+  /// \note The preset loader is refreshed via events or otherwise outside this class's scope
+  PresetChooser(const PresetLoader & presetLoader, bool   softCutRatingsEnabled);
 
-    inline void setSoftCutRatingsEnabled(bool enabled) {
-	_softCutRatingsEnabled = enabled;
-    }
+  inline void setSoftCutRatingsEnabled(bool enabled) {
+    _softCutRatingsEnabled = enabled;
+  }
 
-    /// Choose a preset via the passed in index. Must be between 0 and num valid presets in directory
-    /// \param index An index lying in the interval [0, this->getNumPresets())
-    /// \param presetInputs the preset inputs to associate with the preset upon construction
-    /// \param presetOutputs the preset outputs to associate with the preset upon construction
-    /// \returns an auto pointer of the newly allocated preset
-    std::auto_ptr<Preset> directoryIndex(std::size_t index) const;
+  /// Choose a preset via the passed in index. Must be between 0 and num valid presets in directory
+  /// \param index An index lying in the interval [0, this->getNumPresets())
+  /// \param presetInputs the preset inputs to associate with the preset upon construction
+  /// \param presetOutputs the preset outputs to associate with the preset upon construction
+  /// \returns an auto pointer of the newly allocated preset
+  std::auto_ptr<Preset> directoryIndex(std::size_t index) const;
 
-    /// Gets the number of presets last believed to exist in the preset loader's filename collection
-    /// \returns the number of presets in the collection
-    std::size_t size() const;
+  /// Gets the number of presets last believed to exist in the preset loader's filename collection
+  /// \returns the number of presets in the collection
+  std::size_t size() const;
 
-    /// An STL-esque iterator to begin traversing presets from a directory
-    /// \param index the index to begin iterating at. Assumed valid between [0, num presets)
-    /// \returns the position of the first preset in the collection
-    PresetIterator begin(unsigned int index) const;
+  /// An STL-esque iterator to begin traversing presets from a directory
+  /// \param index the index to begin iterating at. Assumed valid between [0, num presets)
+  /// \returns the position of the first preset in the collection
+  PresetIterator begin(unsigned int index) const;
 
-    /// An STL-esque iterator to begin traversing presets from a directory
-    /// \returns the position of the first preset in the collection
-    PresetIterator begin();
+  /// An STL-esque iterator to begin traversing presets from a directory
+  /// \returns the position of the first preset in the collection
+  PresetIterator begin();
 
-    /// An STL-esque iterator to retrieve an end position from a directory
-    /// \returns the end position of the collection
-    PresetIterator end() const;
+  /// An STL-esque iterator to retrieve an end position from a directory
+  /// \returns the end position of the collection
+  PresetIterator end() const;
 
-    /// Perform a weighted sample to select a preset (uses preset rating values)
-    /// \returns an iterator to the randomly selected preset
-    iterator weightedRandom(bool hardCut) const;
+  /// Perform a weighted sample to select a preset (uses preset rating values)
+  /// \returns an iterator to the randomly selected preset
+  iterator weightedRandom(bool hardCut) const;
 
-    /// True if no presets in directory
-    bool empty() const;
+  /// True if no presets in directory
+  bool empty() const;
 
 
-    inline void nextPreset(PresetIterator & presetPos);
-    inline void previousPreset(PresetIterator & presetPos);
+  inline void nextPreset(PresetIterator & presetPos);
+  inline void previousPreset(PresetIterator & presetPos);
 
 private:
-    std::vector<float> sampleWeights;
-    const PresetLoader * _presetLoader;
-    bool _softCutRatingsEnabled;
+  std::vector<float> sampleWeights;
+  const PresetLoader * _presetLoader;
+  bool _softCutRatingsEnabled;
 };
 
 
-inline PresetChooser::PresetChooser(const PresetLoader & presetLoader, bool softCutRatingsEnabled):_presetLoader(&presetLoader), _softCutRatingsEnabled(softCutRatingsEnabled) {
+inline
+PresetChooser::PresetChooser (
+const PresetLoader  &presetLoader,
+bool                softCutRatingsEnabled
+)
+  : _presetLoader(&presetLoader),
+    _softCutRatingsEnabled(softCutRatingsEnabled)
+{
 
 }
 
-inline std::size_t PresetChooser::size() const {
-    return _presetLoader->size();
+inline std::size_t
+PresetChooser::size() const
+{
+  return _presetLoader->size();
 }
 
-inline void PresetIterator::setChooser(const PresetChooser & chooser) {
-    _presetChooser = &chooser;
+inline void
+PresetIterator::setChooser(const PresetChooser & chooser)
+{
+  _presetChooser = &chooser;
 }
 
-inline std::size_t PresetIterator::operator*() const {
-    return _currentIndex;
+inline std::size_t
+PresetIterator::operator*() const
+{
+  return _currentIndex;
 }
 
 inline PresetIterator::PresetIterator(std::size_t start):_currentIndex(start) {}
 
-inline void PresetIterator::operator++() {
-    assert(_currentIndex < _presetChooser->size());
-    _currentIndex++;
+inline void
+PresetIterator::operator++()
+{
+  assert(_currentIndex < _presetChooser->size());
+  _currentIndex++;
 }
 
-inline void PresetIterator::operator--() {
-    assert(_currentIndex > 0);
-    _currentIndex--;
+inline void
+PresetIterator::operator--()
+{
+  assert(_currentIndex > 0);
+  _currentIndex--;
 }
 
-inline bool PresetIterator::operator !=(const PresetIterator & presetPos) const {
-    return (*presetPos != **this);
+inline bool
+PresetIterator::operator !=(const PresetIterator & presetPos) const
+{
+  return (*presetPos != **this);
 }
 
 
-inline bool PresetIterator::operator ==(const PresetIterator & presetPos) const {
-    return (*presetPos == **this);
+inline bool
+PresetIterator::operator ==(const PresetIterator & presetPos) const
+{
+  return (*presetPos == **this);
 }
 
-inline std::auto_ptr<Preset> PresetIterator::allocate() {
-    return _presetChooser->directoryIndex(_currentIndex);
+inline std::auto_ptr<Preset>
+PresetIterator::allocate()
+{
+  return _presetChooser->directoryIndex(_currentIndex);
 }
 
-inline void PresetChooser::nextPreset(PresetIterator & presetPos) {
+inline void
+PresetChooser::nextPreset(PresetIterator & presetPos)
+{
+  if (this->empty()) {
+    return;
+  }
+  // Case: idle preset currently running, selected first preset of chooser
+  else if (presetPos == this->end())
+    presetPos = this->begin();
+  else
+    ++(presetPos);
 
-		if (this->empty()) {
-			return;
-		}
-
-		// Case: idle preset currently running, selected first preset of chooser
-		else if (presetPos == this->end())
-			presetPos = this->begin();
-		else
-			++(presetPos);
-
-		// Case: already at last preset, loop to beginning
-		if (((presetPos) == this->end())) {
-			presetPos = this->begin();
-		}
-
+  // Case: already at last preset, loop to beginning
+  if (((presetPos) == this->end())) {
+    presetPos = this->begin();
+  }
 }
 
 
-inline void PresetChooser::previousPreset(PresetIterator & presetPos) {
-		if (this->empty())
-			return;
+inline void
+PresetChooser::previousPreset(PresetIterator & presetPos)
+{
+  if (this->empty())
+    return;
 
-		// Case: idle preset currently running, selected last preset of chooser
-		else if (presetPos == this->end()) {
-			--(presetPos);
-		}
-
-		else if (presetPos != this->begin()) {
-			--(presetPos);
-		}
-
-		else {
-		   presetPos = this->end();
-		   --(presetPos);
-		}
+  // Case: idle preset currently running, selected last preset of chooser
+  else if (presetPos == this->end()) {
+    --(presetPos);
+  }
+  else if (presetPos != this->begin()) {
+    --(presetPos);
+  }
+  else {
+    presetPos = this->end();
+    --(presetPos);
+  }
 }
 
-inline PresetIterator PresetChooser::begin() {
-    PresetIterator pos(0);
-    pos.setChooser(*this);
-    return pos;
+inline PresetIterator
+PresetChooser::begin()
+{
+  PresetIterator pos(0);
+  pos.setChooser(*this);
+  return pos;
 }
 
-inline PresetIterator PresetChooser::begin(unsigned int index) const{
-    PresetIterator pos(index);
-    pos.setChooser(*this);
-    return pos;
+inline PresetIterator
+PresetChooser::begin(unsigned int index) const
+{
+  PresetIterator pos(index);
+  pos.setChooser(*this);
+  return pos;
 }
 
-inline PresetIterator PresetChooser::end() const {
-    PresetIterator pos(_presetLoader->size());
-    pos.setChooser(*this);
-    return pos;
+inline PresetIterator
+PresetChooser::end() const
+{
+  PresetIterator pos(_presetLoader->size());
+  pos.setChooser(*this);
+  return pos;
 }
 
 
-inline bool PresetChooser::empty() const {
-	return _presetLoader->size() == 0;
+inline bool
+PresetChooser::empty() const
+{
+  return _presetLoader->size() == 0;
 }
 
-inline std::auto_ptr<Preset> PresetChooser::directoryIndex(std::size_t index) const {
-
-	return _presetLoader->loadPreset(index);
+inline std::auto_ptr<Preset>
+PresetChooser::directoryIndex(std::size_t index) const
+{
+  return _presetLoader->loadPreset(index);
 }
 
 
-inline PresetChooser::iterator PresetChooser::weightedRandom(bool hardCut) const {
+inline PresetChooser::iterator
+PresetChooser::weightedRandom(bool hardCut) const
+{
+  // TODO make a sophisticated function object interface to determine why a certain rating
+  // category is chosen, or weighted distribution thereover.
+  const PresetRatingType ratingType = hardCut || (!_softCutRatingsEnabled) ?
+                                                 HARD_CUT_RATING_TYPE :
+                                                 SOFT_CUT_RATING_TYPE;    
 
-	
-	
+  const std::size_t ratingsTypeIndex = static_cast<std::size_t>(ratingType);
 
-	// TODO make a sophisticated function object interface to determine why a certain rating
-	// category is chosen, or weighted distribution thereover.
-	const PresetRatingType ratingType = hardCut || (!_softCutRatingsEnabled) ? 
-		HARD_CUT_RATING_TYPE : SOFT_CUT_RATING_TYPE;		
+  const std::vector<int> & weights = _presetLoader->getPresetRatings()[ratingsTypeIndex];
 
-	const std::size_t ratingsTypeIndex = static_cast<std::size_t>(ratingType);
-	
-	const std::vector<int> & weights = _presetLoader->getPresetRatings()[ratingsTypeIndex];
+  const std::size_t index = RandomNumberGenerators::weightedRandom
+                             (weights,
+                              _presetLoader->getPresetRatingsSums()[ratingsTypeIndex]);
 
-	const std::size_t index = RandomNumberGenerators::weightedRandom
-		(weights,
-		 _presetLoader->getPresetRatingsSums()[ratingsTypeIndex]);
-	
-	return begin(index);
+  return begin(index);
 }
 
 #endif
diff --git a/src/libprojectM/PresetFactory.cpp b/src/libprojectM/PresetFactory.cpp
index bd7ac16..78e5031 100644
--- a/src/libprojectM/PresetFactory.cpp
+++ b/src/libprojectM/PresetFactory.cpp
@@ -1,24 +1,25 @@
 #include "PresetFactory.hpp"
 
+
 const std::string PresetFactory::IDLE_PRESET_PROTOCOL("idle");
 
-std::string PresetFactory::protocol(const std::string & url, std::string & path) {
 
+std::string
+PresetFactory::protocol (const std::string & url, std::string & path)
+{
 #ifdef __APPLE__
-	// NOTE: Brian changed this from url.find_first_of to url.find, since presumably we want to find the first occurence of
-	// :// and not the first occurence of any colon or forward slash.  At least that fixed a bug in the Mac OS X build.
-	std::size_t pos = url.find("://");
+  // NOTE: Brian changed this from url.find_first_of to url.find, since presumably we want to find the first occurence of
+  // :// and not the first occurence of any colon or forward slash.  At least that fixed a bug in the Mac OS X build.
+  std::size_t pos = url.find("://");
 #else
-	std::size_t pos = url.find_first_of("://");
+  std::size_t pos = url.find_first_of("://");
 #endif
-	if (pos == std::string::npos)
-		return std::string();
-	else {
-		path = url.substr(pos + 3, url.length());
-		std::cout << "[PresetFactory] path is " << path << std::endl;
-		std::cout << "[PresetFactory] url is " << url << std::endl;
-		return url.substr(0, pos);
-	}
-
+  if (pos == std::string::npos)
+    return std::string();
+  else {
+    path = url.substr (pos + 3, url.length());
+    std::cout << "[PresetFactory] path is " << path << std::endl;
+    std::cout << "[PresetFactory] url is " << url << std::endl;
+    return url.substr (0, pos);
+  }
 }
-
diff --git a/src/libprojectM/PresetFactory.hpp b/src/libprojectM/PresetFactory.hpp
index e9c8a4c..4e883e2 100644
--- a/src/libprojectM/PresetFactory.hpp
+++ b/src/libprojectM/PresetFactory.hpp
@@ -9,33 +9,34 @@
 // Copyright: See COPYING file that comes with this distribution
 //
 //
-
 #include "Preset.hpp"
 #include <memory>
 
 #ifndef __PRESET_FACTORY_HPP
 #define __PRESET_FACTORY_HPP
 
+
 class PresetFactory {
 
 public:
- static const std::string IDLE_PRESET_PROTOCOL;
- static std::string protocol(const std::string & url, std::string & path);
+  static const std::string IDLE_PRESET_PROTOCOL;
+  static std::string protocol(const std::string & url, std::string & path);
 
- inline PresetFactory() {}
+  inline PresetFactory() {}
 
- inline virtual ~PresetFactory() {}
+  inline virtual ~PresetFactory() {}
 
- /// Constructs a new preset given an url and optional meta data
- /// \param url a locational identifier referencing the preset
- /// \param name the preset name
- /// \param author the preset author
- /// \returns a valid preset object
- virtual std::auto_ptr<Preset> allocate(const std::string & url, const std::string & name=std::string(),
-	 const std::string & author=std::string()) = 0;
+  /// Constructs a new preset given an url and optional meta data
+  /// \param url a locational identifier referencing the preset
+  /// \param name the preset name
+  /// \param author the preset author
+  /// \returns a valid preset object
+  virtual std::auto_ptr<Preset> allocate (const std::string & url,
+                                          const std::string & name=std::string(),
+                                          const std::string & author=std::string()) = 0;
 
- /// Returns a space separated list of supported extensions
- virtual std::string supportedExtensions() const = 0;
+  /// Returns a space separated list of supported extensions
+  virtual std::string supportedExtensions() const = 0;
 
 };
 
diff --git a/src/libprojectM/PresetFactoryManager.cpp b/src/libprojectM/PresetFactoryManager.cpp
index 7dea038..b383107 100644
--- a/src/libprojectM/PresetFactoryManager.cpp
+++ b/src/libprojectM/PresetFactoryManager.cpp
@@ -1,7 +1,7 @@
 //
 // C++ Implementation: PresetFactoryManager
 //
-// Description: 
+// Description:
 //
 //
 // Author: Carmelo Piccione <carmelo.piccione@gmail.com>, (C) 2008
@@ -20,71 +20,92 @@
 #endif
 
 #include <sstream>
-PresetFactoryManager::PresetFactoryManager() : _gx(0), _gy(0), initialized(false) {}
 
-PresetFactoryManager::~PresetFactoryManager() {
-	for (std::vector<PresetFactory *>::iterator pos = _factoryList.begin(); 
-		pos != _factoryList.end(); ++pos) {
-		assert(*pos);
-		delete(*pos);
-	}
+
+PresetFactoryManager::PresetFactoryManager()
+  : _gx (0), _gy (0), initialized (false)
+{}
+
+PresetFactoryManager::~PresetFactoryManager()
+{
+  for (std::vector<PresetFactory *>::iterator pos = _factoryList.begin();
+       pos != _factoryList.end();
+       ++pos)
+  {
+    assert (*pos);
+    delete (*pos);
+  }
 
   initialized = false;
 }
 
-void PresetFactoryManager::initialize(int gx, int gy) {
-	_gx = gx;
-	_gy = gy;
-	
-	if (!initialized) {
-	  initialized = true;
-	} else {
-	  std::cout << "already initialized " << std::endl;
-	  return;
-	}
-	  
-	PresetFactory * factory;
-	
-	#ifndef DISABLE_MILKDROP_PRESETS
-	factory = new MilkdropPresetFactory(_gx, _gy);
-	registerFactory(factory->supportedExtensions(), factory);		
-	#endif
-	
-	#ifndef DISABLE_NATIVE_PRESETS
-	factory = new NativePresetFactory();
-	registerFactory(factory->supportedExtensions(), factory);
-	#endif
+void
+PresetFactoryManager::initialize (int gx, int gy)
+{
+  _gx = gx;
+  _gy = gy;
+
+  if (!initialized) {
+    initialized = true;
+  } else {
+    std::cout << "already initialized " << std::endl;
+    return;
+  }
+
+  PresetFactory * factory;
+
+  #ifndef DISABLE_MILKDROP_PRESETS
+  factory = new MilkdropPresetFactory (_gx, _gy);
+  registerFactory (factory->supportedExtensions(), factory);
+  #endif
+
+  #ifndef DISABLE_NATIVE_PRESETS
+  factory = new NativePresetFactory();
+  registerFactory (factory->supportedExtensions(), factory);
+  #endif
 }
 
 // Current behavior if a conflict is occurs is to override the previous request
 
-void PresetFactoryManager::registerFactory(const std::string & extensions, PresetFactory * factory) {
-	
-	std::stringstream ss(extensions);	
-	std::string extension;
+void
+PresetFactoryManager::registerFactory
+(
+const std::string &extensions,
+PresetFactory     *factory
+)
+{
+  std::stringstream ss (extensions);
+  std::string       extension;
 
-	_factoryList.push_back(factory);
+  _factoryList.push_back (factory);
 
-	while (ss >> extension) {
-		if (_factoryMap.count(extension)) {
-			std::cerr << "[PresetFactoryManager] Warning: extension \"" << extension << 
-				"\" already has a factory. New factory handler ignored." << std::endl;			
-		} else {
-			_factoryMap.insert(std::make_pair(extension, factory));			
-		}
-	}
+  while (ss >> extension) {
+    if (_factoryMap.count (extension)) {
+      std::cerr << "[PresetFactoryManager] Warning: extension \""
+                << extension
+                << "\" already has a factory. New factory handler ignored."
+                << std::endl;
+    } else {
+      _factoryMap.insert (std::make_pair (extension, factory));
+    }
+  }
 }
 
-PresetFactory & PresetFactoryManager::factory(const std::string & extension) {
+PresetFactory &
+PresetFactoryManager::factory (const std::string & extension)
+{
 
-	if (!_factoryMap.count(extension)) {		
-		std::ostringstream os;
-		os << "No factory associated with \"" << extension << "\"." << std::endl;
-		throw PresetFactoryException(os.str());
-	}
-	return *_factoryMap[extension];
+  if (!_factoryMap.count (extension)) {
+    std::ostringstream os;
+
+    os << "No factory associated with \"" << extension << "\"." << std::endl;
+    throw PresetFactoryException (os.str());
+  }
+  return *_factoryMap[extension];
 }
 
-bool PresetFactoryManager::extensionHandled(const std::string & extension) const {		
-	return _factoryMap.count(extension);
+bool
+PresetFactoryManager::extensionHandled (const std::string & extension) const
+{
+  return _factoryMap.count (extension);
 }
diff --git a/src/libprojectM/PresetFactoryManager.hpp b/src/libprojectM/PresetFactoryManager.hpp
index 2dfa0a0..899b229 100644
--- a/src/libprojectM/PresetFactoryManager.hpp
+++ b/src/libprojectM/PresetFactoryManager.hpp
@@ -11,49 +11,53 @@
 //
 #ifndef __PRESET_FACTORY_MANAGER_HPP
 #define __PRESET_FACTORY_MANAGER_HPP
+
 #include "PresetFactory.hpp"
 
+
 /// A simple exception class to strongly type all preset factory related issues
 class PresetFactoryException : public std::exception
 {
-	public:
-		inline PresetFactoryException(const std::string & message) : _message(message) {}
-		virtual ~PresetFactoryException() throw() {}
-		const std::string & message() const { return _message; } 
+public:
+  inline            PresetFactoryException (const std::string & message) : _message(message) {}
+  virtual           ~PresetFactoryException() throw() {}
+  const std::string &message() const { return _message; } 
 
-	private:
-		std::string _message;
+private:
+  std::string _message;
 };
 
 /// A manager of preset factories
 class PresetFactoryManager {
 
-	public:
-		PresetFactoryManager();
-		~PresetFactoryManager();
+public:
+  PresetFactoryManager();
+  ~PresetFactoryManager();
 
-		/// Initializes the manager with mesh sizes specified
-		/// \param gx the width of the mesh
-		/// \param gy the height of the mesh
-		/// \note This must be called once before any other methods
-		void initialize(int gx, int gy);
-		
-		/// Requests a factory given a preset extension type
-		/// \param extension a string denoting the preset suffix type
-		/// \throws PresetFactoryException if the extension is unhandled
-		/// \returns a valid preset factory associated with the extension
-		PresetFactory & factory(const std::string & extension);
+  /// Initializes the manager with mesh sizes specified
+  /// \param gx the width of the mesh
+  /// \param gy the height of the mesh
+  /// \note This must be called once before any other methods
+  void initialize (int gx, int gy);
 
-		/// Tests if an extension has been registered with a factory
-		/// \param extension the file name extension to verify
-		/// \returns true if a factory exists, false otherwise
-		bool extensionHandled(const std::string & extension) const;
+  /// Requests a factory given a preset extension type
+  /// \param extension a string denoting the preset suffix type
+  /// \throws PresetFactoryException if the extension is unhandled
+  /// \returns a valid preset factory associated with the extension
+  PresetFactory & factory (const std::string & extension);
 
-	private:
-		int _gx, _gy;				
-		mutable std::map<std::string, PresetFactory *> _factoryMap;
-		mutable std::vector<PresetFactory *> _factoryList;
-		void registerFactory(const std::string & extension, PresetFactory * factory);
-		volatile bool initialized;
+  /// Tests if an extension has been registered with a factory
+  /// \param extension the file name extension to verify
+  /// \returns true if a factory exists, false otherwise
+  bool extensionHandled (const std::string & extension) const;
+
+private:
+  mutable std::map<std::string, PresetFactory *>  _factoryMap;
+  mutable std::vector<PresetFactory *>            _factoryList;
+  int             _gx, _gy;       
+  volatile bool   initialized;
+
+  void registerFactory (const std::string & extension, PresetFactory * factory);
 };
+
 #endif
diff --git a/src/libprojectM/PresetLoader.cpp b/src/libprojectM/PresetLoader.cpp
index e0afec5..1542db3 100644
--- a/src/libprojectM/PresetLoader.cpp
+++ b/src/libprojectM/PresetLoader.cpp
@@ -35,249 +35,281 @@
 
 #include "Common.hpp"
 
-PresetLoader::PresetLoader (int gx, int gy, std::string dirname = std::string()) :_dirname ( dirname ), _dir ( 0 )
+
+PresetLoader::PresetLoader (int gx, int gy, std::string dirname = std::string())
+ : _dirname (dirname),
+   _dir (0)
 {
-	_presetFactoryManager.initialize(gx,gy);
-	// Do one scan
-	if ( _dirname != std::string() )
-		rescan();
-	else
-		clear();
+  _presetFactoryManager.initialize (gx, gy);
+  // Do one scan
+  if (_dirname != std::string())
+    rescan();
+  else
+    clear();
 }
 
 PresetLoader::~PresetLoader()
 {
-	if ( _dir )
-		closedir ( _dir );
+  if (_dir)
+    closedir (_dir);
 }
 
-void PresetLoader::setScanDirectory ( std::string dirname )
+void
+PresetLoader::setScanDirectory (std::string dirname)
 {
-	_dirname = dirname;
+  _dirname = dirname;
 }
 
 
-void PresetLoader::rescan()
+void
+PresetLoader::rescan()
 {
-	// std::cerr << "Rescanning..." << std::endl;
+  // std::cerr << "Rescanning..." << std::endl;
 
-	// Clear the directory entry collection
-	clear();
-	
-	// If directory already opened, close it first
-	if ( _dir )
-	{
-		closedir ( _dir );
-		_dir = 0;
-	}
+  // Clear the directory entry collection
+  clear();
 
-	// Allocate a new a stream given the current directory name
-	if ( ( _dir = opendir ( _dirname.c_str() ) ) == NULL )
-	{
-		handleDirectoryError();
-		return; // no files loaded. _entries is empty
-	}
+  // If directory already opened, close it first
+  if (_dir)
+  {
+    closedir (_dir);
+    _dir = 0;
+  }
 
-	struct dirent * dir_entry;
-	std::set<std::string> alphaSortedFileSet;
-	std::set<std::string> alphaSortedPresetNameSet;
+  // Allocate a new a stream given the current directory name
+  if ((_dir = opendir (_dirname.c_str())) == NULL)
+  {
+    handleDirectoryError();
+    return; // no files loaded. _entries is empty
+  }
 
-	while ( ( dir_entry = readdir ( _dir ) ) != NULL )
-	{
+  struct dirent         *dir_entry;
+  std::set<std::string> alphaSortedFileSet;
+  std::set<std::string> alphaSortedPresetNameSet;
+
+  while ((dir_entry = readdir (_dir)) != NULL)
+  {
     if (dir_entry->d_name == 0)
       continue;
 
-		std::ostringstream out;
-		// Convert char * to friendly string
-		std::string filename ( dir_entry->d_name );
+    std::ostringstream  out;
+    // Convert char * to friendly string
+    std::string         filename (dir_entry->d_name);
 
-		// Verify extension is projectm or milkdrop
-		if (!_presetFactoryManager.extensionHandled(parseExtension(filename)))
-			continue;
+    // Verify extension is projectm or milkdrop
+    if (!_presetFactoryManager.extensionHandled (parseExtension (filename)))
+      continue;
 
-		if ( filename.length() > 0 && filename[0] == '.' )
-			continue;
+    if (filename.length() > 0  &&  filename[0] == '.')
+      continue;
 
-		// Create full path name
-		out << _dirname << PATH_SEPARATOR << filename;
+    // Create full path name
+    out << _dirname << PATH_SEPARATOR << filename;
 
-		// Add to our directory entry collection
-		alphaSortedFileSet.insert ( out.str() );
-		alphaSortedPresetNameSet.insert ( filename );
+    // Add to our directory entry collection
+    alphaSortedFileSet.insert (out.str());
+    alphaSortedPresetNameSet.insert (filename);
 
-		// the directory entry struct is freed elsewhere
-	}
+    // the directory entry struct is freed elsewhere
+  }
 
-	// Push all entries in order from the file set to the file entries member (which is an indexed vector)
-	for ( std::set<std::string>::iterator pos = alphaSortedFileSet.begin();
-	        pos != alphaSortedFileSet.end();++pos )
-		_entries.push_back ( *pos );
+  // Push all entries in order from the file set to the file entries member (which is an indexed vector)
+  for (std::set<std::string>::iterator pos = alphaSortedFileSet.begin();
+       pos != alphaSortedFileSet.end();
+       ++pos)
+  {
+    _entries.push_back (*pos);
+  }
 
-	// Push all preset names in similar fashion
-	for ( std::set<std::string>::iterator pos = alphaSortedPresetNameSet.begin();
-	        pos != alphaSortedPresetNameSet.end();++pos )
-		_presetNames.push_back ( *pos );
+  // Push all preset names in similar fashion
+  for (std::set<std::string>::iterator pos = alphaSortedPresetNameSet.begin();
+       pos != alphaSortedPresetNameSet.end();
+       ++pos)
+  {
+    _presetNames.push_back (*pos);
+  }
 
-	// Give all presets equal rating of 3 - why 3? I don't know
-	_ratings = std::vector<RatingList>(TOTAL_RATING_TYPES, RatingList( _presetNames.size(), 3 ));
-	_ratingsSums = std::vector<int>(TOTAL_RATING_TYPES, 3 * _presetNames.size());
-	
-
-	assert ( _entries.size() == _presetNames.size() );
+  // Give all presets equal rating of 3 - why 3? I don't know
+  _ratings = std::vector<RatingList>(TOTAL_RATING_TYPES, RatingList (_presetNames.size(), 3));
+  _ratingsSums = std::vector<int>(TOTAL_RATING_TYPES, 3 * _presetNames.size());
 
 
-
+  assert (_entries.size() == _presetNames.size());
 }
 
 
-std::auto_ptr<Preset> PresetLoader::loadPreset ( unsigned int index )  const
+std::auto_ptr<Preset>
+PresetLoader::loadPreset (unsigned int index)  const
 {
+  // Check that index isn't insane
+  assert (index >= 0);
+  assert (index < _entries.size());
 
-	// Check that index isn't insane
-	assert ( index >= 0 );
-	assert ( index < _entries.size() );
+  // Return a new autopointer to a preset
+  const std::string extension = parseExtension (_entries[index]);
 
-	// Return a new autopointer to a preset
-	const std::string extension = parseExtension ( _entries[index] );
-
-	return _presetFactoryManager.factory(extension).allocate
-		( _entries[index], _presetNames[index] );
-
+  return _presetFactoryManager
+         .factory (extension)
+         .allocate (_entries[index], _presetNames[index]);
 }
 
 
-std::auto_ptr<Preset> PresetLoader::loadPreset ( const std::string & url )  const
+std::auto_ptr<Preset>
+PresetLoader::loadPreset (const std::string & url)  const
 {
+  // Return a new autopointer to a preset
+  const std::string extension = parseExtension (url);
 
-	// Return a new autopointer to a preset
-	const std::string extension = parseExtension ( url );
-
-	/// @bug probably should not use url for preset name
-	return _presetFactoryManager.factory(extension).allocate
-		(url, url);
-
+  /// @bug probably should not use url for preset name
+  return _presetFactoryManager
+         .factory (extension)
+         .allocate (url, url);
 }
 
-void PresetLoader::handleDirectoryError()
+void
+PresetLoader::handleDirectoryError()
 {
 
 #ifdef WIN32
-	std::cerr << "[PresetLoader] warning: errno unsupported on win32 platforms. fix me" << std::endl;
+  std::cerr << "[PresetLoader] warning: errno unsupported on win32 platforms. fix me" << std::endl;
 #else
 
-	switch ( errno )
-	{
-		case ENOENT:
-			std::cerr << "[PresetLoader] ENOENT error. The path \"" << this->_dirname << "\" probably does not exist. \"man open\" for more info." << std::endl;
-			break;
-		case ENOMEM:
-			std::cerr << "[PresetLoader] out of memory! Are you running Windows?" << std::endl;
-			abort();
-		case ENOTDIR:
-			std::cerr << "[PresetLoader] directory specified is not a preset directory! Trying to continue..." << std::endl;
-			break;
-		case ENFILE:
-			std::cerr << "[PresetLoader] Your system has reached its open file limit. Trying to continue..." << std::endl;
-			break;
-		case EMFILE:
-			std::cerr << "[PresetLoader] too many files in use by projectM! Bailing!" << std::endl;
-			break;
-		case EACCES:
-			std::cerr << "[PresetLoader] permissions issue reading the specified preset directory." << std::endl;
-			break;
-		default:
-			break;
-	}
+  switch (errno) {
+  case ENOENT:
+    std::cerr << "[PresetLoader] ENOENT error. The path \""
+              << this->_dirname
+              << "\" probably does not exist. \"man open\" for more info."
+              << std::endl;
+    break;
+  case ENOMEM:
+    std::cerr << "[PresetLoader] out of memory! Are you running Windows?"
+              << std::endl;
+    abort();
+  case ENOTDIR:
+    std::cerr << "[PresetLoader] directory specified is not a preset directory! Trying to continue..."
+              << std::endl;
+    break;
+  case ENFILE:
+    std::cerr << "[PresetLoader] Your system has reached its open file limit. Trying to continue..."
+              << std::endl;
+    break;
+  case EMFILE:
+    std::cerr << "[PresetLoader] too many files in use by projectM! Bailing!"
+              << std::endl;
+    break;
+  case EACCES:
+    std::cerr << "[PresetLoader] permissions issue reading the specified preset directory."
+              << std::endl;
+    break;
+  default:
+    break;
+  }
 #endif
 }
 
-void PresetLoader::setRating(unsigned int index, int rating, const PresetRatingType ratingType)
+void
+PresetLoader::setRating (unsigned int index, int rating, const PresetRatingType ratingType)
 {
-	assert ( index >=0 );
-	
-	const unsigned int ratingTypeIndex = static_cast<unsigned int>(ratingType);
-	assert (index < _ratings[ratingTypeIndex].size());
- 
-	_ratingsSums[ratingTypeIndex] -= _ratings[ratingTypeIndex][index];
+  assert (index >=0);
 
-	_ratings[ratingTypeIndex][index] = rating;
-	_ratingsSums[ratingType] += rating;
+  const unsigned int ratingTypeIndex = static_cast<unsigned int>(ratingType);
+  assert (index < _ratings[ratingTypeIndex].size());
 
+  _ratingsSums[ratingTypeIndex] -= _ratings[ratingTypeIndex][index];
+
+  _ratings[ratingTypeIndex][index] = rating;
+  _ratingsSums[ratingType] += rating;
 }
 
 
-unsigned int PresetLoader::addPresetURL ( const std::string & url, const std::string & presetName, const std::vector<int> & ratings)
+unsigned int
+PresetLoader::addPresetURL (
+const std::string       & url,
+const std::string       & presetName,
+const std::vector<int>  & ratings
+)
 {
-	_entries.push_back(url);
-	_presetNames.push_back ( presetName );
+  _entries.push_back (url);
+  _presetNames.push_back (presetName);
 
-	assert(ratings.size() == TOTAL_RATING_TYPES);
-	assert(ratings.size() == _ratings.size());
+  assert (ratings.size() == TOTAL_RATING_TYPES);
+  assert (ratings.size() == _ratings.size());
 
-	for (int i = 0; i < _ratings.size(); i++)
-		_ratings[i].push_back(ratings[i]);
+  for (int i = 0;  i < _ratings.size();  i++)
+    _ratings[i].push_back (ratings[i]);
 
-	for (int i = 0; i < ratings.size(); i++)
-		_ratingsSums[i] += ratings[i];
-	
-	return _entries.size()-1;
+  for (int i = 0;  i < ratings.size();  i++)
+    _ratingsSums[i] += ratings[i];
+
+  return _entries.size() - 1;
 }
 
-void PresetLoader::removePreset ( unsigned int index )
+void
+PresetLoader::removePreset (unsigned int index)
 {
+  _entries.erase (_entries.begin() + index);
+  _presetNames.erase (_presetNames.begin() + index);
 
-	_entries.erase ( _entries.begin() + index );
-	_presetNames.erase ( _presetNames.begin() + index );
-	
-	for (int i = 0; i < _ratingsSums.size(); i++) {
-		_ratingsSums[i] -= _ratings[i][index];
-		_ratings[i].erase ( _ratings[i].begin() + index );
-	}
-	
-
+  for (int i = 0;  i < _ratingsSums.size();  i++) {
+    _ratingsSums[i] -= _ratings[i][index];
+    _ratings[i].erase (_ratings[i].begin() + index);
+  }
 }
 
-const std::string & PresetLoader::getPresetURL ( unsigned int index ) const
+const std::string &
+PresetLoader::getPresetURL (unsigned int index) const
 {
-	return _entries[index];
+  return _entries[index];
 }
 
-const std::string & PresetLoader::getPresetName ( unsigned int index ) const
+const std::string &
+PresetLoader::getPresetName (unsigned int index) const
 {
-	return _presetNames[index];
+  return _presetNames[index];
 }
 
-int PresetLoader::getPresetRating ( unsigned int index, const PresetRatingType ratingType ) const
+int
+PresetLoader::getPresetRating (
+unsigned int            index,
+const PresetRatingType  ratingType
+) const
 {
-	return _ratings[ratingType][index];
+  return _ratings[ratingType][index];
 }
 
-const std::vector<RatingList> & PresetLoader::getPresetRatings () const
+const std::vector<RatingList> &
+PresetLoader::getPresetRatings() const
 {
-	return _ratings;
+  return _ratings;
 }
 
-const std::vector<int> & PresetLoader::getPresetRatingsSums() const {
-	return _ratingsSums;
-}
-
-void PresetLoader::setPresetName(unsigned int index, std::string name) {
-	_presetNames[index] = name;
-}
-
-void PresetLoader::insertPresetURL ( unsigned int index, const std::string & url, const std::string & presetName, const RatingList & ratings)
+const std::vector<int> &
+PresetLoader::getPresetRatingsSums() const
 {
-	_entries.insert ( _entries.begin() + index, url );
-	_presetNames.insert ( _presetNames.begin() + index, presetName );
-	
-	
+  return _ratingsSums;
+}
 
-	for (int i = 0; i < _ratingsSums.size();i++) {
-		_ratingsSums[i] += _ratings[i][index];
-		_ratings[i].insert ( _ratings[i].begin() + index, ratings[i] );
-	}
+void
+PresetLoader::setPresetName (unsigned int index, std::string name)
+{
+  _presetNames[index] = name;
+}
 
-	assert ( _entries.size() == _presetNames.size() );
-	
-	
+void
+PresetLoader::insertPresetURL (
+unsigned int      index,
+const std::string & url,
+const std::string & presetName,
+const RatingList  & ratings
+)
+{
+  _entries.insert (_entries.begin() + index, url);
+  _presetNames.insert (_presetNames.begin() + index, presetName);
+
+  for (int i = 0;  i < _ratingsSums.size();  i++) {
+    _ratingsSums[i] += _ratings[i][index];
+    _ratings[i].insert (_ratings[i].begin() + index, ratings[i]);
+  }
+
+  assert (_entries.size() == _presetNames.size());
 }
diff --git a/src/libprojectM/PresetLoader.hpp b/src/libprojectM/PresetLoader.hpp
index 02d43c1..d83e548 100644
--- a/src/libprojectM/PresetLoader.hpp
+++ b/src/libprojectM/PresetLoader.hpp
@@ -21,98 +21,98 @@
 #include <map>
 #include "PresetFactoryManager.hpp"
 
+
 class Preset;
 class PresetFactory;
 
 
 class PresetLoader {
-	public:
-		
-		
-		/// Initializes the preset loader with the target directory specified 
-		PresetLoader(int gx, int gy, std::string dirname);
-				
-		~PresetLoader();
-	
-		/// Load a preset by specifying it's unique identifier given when the preset url
-		/// was added to this loader	
-		std::auto_ptr<Preset> loadPreset(unsigned int index) const;
-		std::auto_ptr<Preset> loadPreset ( const std::string & url )  const;
-		/// Add a preset to the loader's collection.
-		/// \param url an url referencing the preset
-		/// \param presetName a name for the preset
-		/// \param rating an integer representing the goodness of the preset
-		/// \returns The unique index assigned to the preset in the collection. Used with loadPreset
-		unsigned int addPresetURL ( const std::string & url, const std::string & presetName, const RatingList & ratings);
-			
-		/// Add a preset to the loader's collection.
-		/// \param index insertion index
-		/// \param url an url referencing the preset
-		/// \param presetName a name for the preset
-		/// \param rating an integer representing the goodness of the preset
-		void insertPresetURL (unsigned int index, const std::string & url, const std::string & presetName, const RatingList & ratings);
-	
-		/// Clears all presets from the collection
-		inline void clear() { 
-			_entries.clear(); _presetNames.clear(); 
-			_ratings = std::vector<RatingList>(TOTAL_RATING_TYPES, RatingList());
-			clearRatingsSum();
- 		}
+public:
 
-		inline void clearRatingsSum() {
-			_ratingsSums = std::vector<int>(TOTAL_RATING_TYPES, 0);
-		}
-		
-		const std::vector<RatingList> & getPresetRatings() const;		
-		const std::vector<int> & getPresetRatingsSums() const;
+  /// Initializes the preset loader with the target directory specified 
+  PresetLoader(int gx, int gy, std::string dirname);
 
-		/// Removes a preset from the loader
-		/// \param index the unique identifier of the preset url to be removed
-		void removePreset(unsigned int index);
+  ~PresetLoader();
 
-		/// Sets the rating of a preset to a new value
-		void setRating(unsigned int index, int rating, const PresetRatingType ratingType);
-		
-		/// Get a preset rating given an index
-		int getPresetRating ( unsigned int index, const PresetRatingType ratingType) const;
-		
-		/// Get a preset url given an index
-		const std::string & getPresetURL ( unsigned int index) const;
-		
-		/// Get a preset name given an index
-		const std::string & getPresetName ( unsigned int index) const;
-		
-		/// Returns the number of presets in the active directory 
-		inline std::size_t size() const {
-			return _entries.size();
-		}
-					
-		/// Sets the directory where the loader will search for files 
-		void setScanDirectory(std::string pathname);
+  /// Load a preset by specifying it's unique identifier given when the preset url
+  /// was added to this loader  
+  std::auto_ptr<Preset> loadPreset(unsigned int index) const;
+  std::auto_ptr<Preset> loadPreset ( const std::string & url )  const;
+  /// Add a preset to the loader's collection.
+  /// \param url an url referencing the preset
+  /// \param presetName a name for the preset
+  /// \param rating an integer representing the goodness of the preset
+  /// \returns The unique index assigned to the preset in the collection. Used with loadPreset
+  unsigned int addPresetURL ( const std::string & url, const std::string & presetName, const RatingList & ratings);
 
-		/// Returns the directory path associated with this preset chooser
-		inline const std::string & directoryName() const {
-			return _dirname;
-		}
-		
-		/// Rescans the active preset directory
-		void rescan();
-		void setPresetName(unsigned int index, std::string name);
-	private:
-		void handleDirectoryError();
-		std::string _dirname;
-		DIR * _dir;
-		std::vector<int> _ratingsSums;
-		mutable PresetFactoryManager _presetFactoryManager;
+  /// Add a preset to the loader's collection.
+  /// \param index insertion index
+  /// \param url an url referencing the preset
+  /// \param presetName a name for the preset
+  /// \param rating an integer representing the goodness of the preset
+  void insertPresetURL (unsigned int index, const std::string & url, const std::string & presetName, const RatingList & ratings);
 
-		// vector chosen for speed, but not great for reverse index lookups
-		std::vector<std::string> _entries;
-		std::vector<std::string> _presetNames;
+  /// Clears all presets from the collection
+  inline void clear() { 
+    _entries.clear(); _presetNames.clear(); 
+    _ratings = std::vector<RatingList>(TOTAL_RATING_TYPES, RatingList());
+    clearRatingsSum();
+  }
 
-		// Indexed by ratingType, preset position.
-		std::vector<RatingList> _ratings;
-		
+  inline void clearRatingsSum() {
+    _ratingsSums = std::vector<int>(TOTAL_RATING_TYPES, 0);
+  }
 
+  const std::vector<RatingList> & getPresetRatings() const;   
+  const std::vector<int> & getPresetRatingsSums() const;
+
+  /// Removes a preset from the loader
+  /// \param index the unique identifier of the preset url to be removed
+  void removePreset(unsigned int index);
+
+  /// Sets the rating of a preset to a new value
+  void setRating(unsigned int index, int rating, const PresetRatingType ratingType);
+
+  /// Get a preset rating given an index
+  int getPresetRating ( unsigned int index, const PresetRatingType ratingType) const;
+
+  /// Get a preset url given an index
+  const std::string & getPresetURL ( unsigned int index) const;
+
+  /// Get a preset name given an index
+  const std::string & getPresetName ( unsigned int index) const;
+
+  /// Returns the number of presets in the active directory 
+  inline std::size_t size() const {
+    return _entries.size();
+  }
+
+  /// Sets the directory where the loader will search for files 
+  void setScanDirectory(std::string pathname);
+
+  /// Returns the directory path associated with this preset chooser
+  inline const std::string & directoryName() const {
+    return _dirname;
+  }
+
+  /// Rescans the active preset directory
+  void rescan();
+  void setPresetName(unsigned int index, std::string name);
+
+private:
+  void handleDirectoryError();
+
+  std::string                   _dirname;
+  DIR                           *_dir;
+  std::vector<int>              _ratingsSums;
+  mutable PresetFactoryManager  _presetFactoryManager;
+
+  // vector chosen for speed, but not great for reverse index lookups
+  std::vector<std::string>      _entries;
+  std::vector<std::string>      _presetNames;
+
+  // Indexed by ratingType, preset position.
+  std::vector<RatingList>       _ratings;
 };
 
 #endif
diff --git a/src/libprojectM/RandomNumberGenerators.hpp b/src/libprojectM/RandomNumberGenerators.hpp
index 862e43b..008585a 100644
--- a/src/libprojectM/RandomNumberGenerators.hpp
+++ b/src/libprojectM/RandomNumberGenerators.hpp
@@ -7,116 +7,136 @@
 
 #define WEIGHTED_RANDOM_DEBUG 0
 
+
 namespace RandomNumberGenerators {
 
-inline float uniform()
-/* Uniform random number generator x(n+1)= a*x(n) mod c
-				with a = pow(7,5) and c = pow(2,31)-1.
-				Copyright (c) Tao Pang 1997. */
-	{
-		const int ia=16807,ic=2147483647,iq=127773,ir=2836;
-		int il,ih,it;
-		float rc;
-		static int iseed = rand();
-		ih = iseed/iq;
-		il = iseed%iq;
-		it = ia*il-ir*ih;
-		if (it > 0)
-		{
-			iseed = it;
-		}
-		else
-		{
-			iseed = ic+it;
-		}
-		rc = ic;
-		return iseed/rc;
-	}
 
-inline float gaussian(float mean, float sigma)
+inline float
+uniform()
+/* Uniform random number generator x(n+1)= a*x(n) mod c
+        with a = pow(7,5) and c = pow(2,31)-1.
+        Copyright (c) Tao Pang 1997. */
+{
+  const int   ia=16807,
+              ic=2147483647,
+              iq=127773,
+              ir=2836;
+  int         il,ih,it;
+  float       rc;
+  static int  iseed = rand();
+
+  ih = iseed / iq;
+  il = iseed % iq;
+  it = ia * il - ir * ih;
+  if (it > 0)
+  {
+    iseed = it;
+  }
+  else
+  {
+    iseed = ic+it;
+  }
+  rc = ic;
+  return iseed / rc;
+}
+
+inline float
+gaussian (float mean, float sigma)
 {
 
-	float x1, x2, w, y1, y2;
- 
-	do {
-		x1 = 2.0 * uniform() - 1.0;
-		x2 = 2.0 * uniform() - 1.0;
-		w = x1 * x1 + x2 * x2;
-	} while ( w >= 1.0 );
+  float x1, x2, w, y1, y2;
 
-	w = sqrt( (-2.0 * log( w ) ) / w );
-	y1 = x1 * w;
-	y2 = x2 * w;
-	
-	float ret = y1*sigma + mean;
+  do {
+    x1 = 2.0 * uniform() - 1.0;
+    x2 = 2.0 * uniform() - 1.0;
+    w = x1 * x1 + x2 * x2;
+  } while ( w >= 1.0 );
 
-	return ret;
+  w = sqrt( (-2.0 * log( w ) ) / w );
+  y1 = x1 * w;
+  y2 = x2 * w;
+
+  float ret = y1*sigma + mean;
+
+  return ret;
 }
 
-inline std::size_t uniformInteger(std::size_t upperBound=1) {
-
-	
-	/// @bug there was a man entry about how this leads to a lousy uniform
-	/// @bug distribution in practice. should probably review
-	assert(upperBound > 0);
-	return ((rand()) % ((int)upperBound));
+inline std::size_t
+uniformInteger (std::size_t upperBound = 1)
+{
+  /// @bug there was a man entry about how this leads to a lousy uniform
+  /// @bug distribution in practice. should probably review
+  assert(upperBound > 0);
+  return ((rand()) % ((int)upperBound));
 }
 
-	
-	
+
+
 
 /// Randomizes from probabilistically weighted distribution. Thus,
 /// sum of passed in weights should be 1.0
-inline std::size_t weightedRandomNormalized(std::vector<float> weights) {
+inline std::size_t
+weightedRandomNormalized(std::vector<float> weights)
+{
+  // Choose a random bounded mass between 0 and 1
+  float cutoff = ((float) (rand())) / (float) RAND_MAX;
 
-        // Choose a random bounded mass between 0 and 1
-	float cutoff = ((float)(rand())) / (float)RAND_MAX;
+  //std::cout << "cutoff : " << cutoff << std::endl;
 
-	//std::cout << "cutoff : " << cutoff << std::endl;
+  // Sum up mass, stopping when cutoff is reached. This is the typical
+  // weighted sampling algorithm.
+  float mass = 0;
+  for (std::size_t i = 0;  i < weights.size();   i++) {
+    mass += weights[i];
+    //std::cout << "mass: " << mass << std::endl;
+    if (mass >= cutoff)
+      return i;
+  }
 
-    // Sum up mass, stopping when cutoff is reached. This is the typical
-    // weighted sampling algorithm.
-	float mass = 0;
-	for (std::size_t i = 0; i< weights.size() ; i++) {
-		mass += weights[i];
-		//std::cout << "mass: " << mass << std::endl;
-		if (mass >= cutoff)
-			return i;
-	}
-
-    // Just in case something slips through the cracks
-	return weights.size()-1;
+  // Just in case something slips through the cracks
+  return weights.size()-1;
 }
 
-inline std::size_t weightedRandom(const std::vector<int> & weights, unsigned int weightTotalHint = 0) {
-	
+inline std::size_t
+weightedRandom (const std::vector<int> & weights, unsigned int weightTotalHint = 0)
+{
+  if (weightTotalHint == 0) {
+    for (std::size_t i = 0;  i < weights.size();  i++)
+      weightTotalHint += weights[i];
+  }
 
-	if (weightTotalHint == 0)	{		
-		for (std::size_t i = 0; i < weights.size();i++) 
-			weightTotalHint += weights[i];
-	}
-	
-	const int sampledSum = uniformInteger(weightTotalHint);
-	int sum = 0;
-	if (WEIGHTED_RANDOM_DEBUG) std::cout << "[RNG::weightedRandom()] weightTotal = " << weightTotalHint <<
-			 std::endl; 
+  const int sampledSum = uniformInteger(weightTotalHint);
+  int sum = 0;
 
-	for (std::size_t i = 0; i < weights.size();i++) {
-		if (WEIGHTED_RANDOM_DEBUG) 
-		std::cout << "[RNG::weightedRandom()] weight[" << i << "] = " << weights[i] <<
-			 std::endl; 
+  if (WEIGHTED_RANDOM_DEBUG)
+    std::cout << "[RNG::weightedRandom()] weightTotal = "
+              << weightTotalHint
+              << std::endl;
 
-		sum += weights[i];
-		if (sampledSum <= sum) {
-			if (WEIGHTED_RANDOM_DEBUG) 
-			std::cout << "[RNG::weightedRandom()] sampled index " << i << "(" <<
-			 "running sum = " << sum << ", sampled sum = " << sampledSum << std::endl;
-			return i;
-		}
-	}
+  for (std::size_t i = 0;  i < weights.size();  i++) {
+    if (WEIGHTED_RANDOM_DEBUG)
+      std::cout << "[RNG::weightedRandom()] weight[" << i << "] = "
+                << weights[i]
+                << std::endl;
 
-	return weights.size()-1;
+    sum += weights[i];
+    if (sampledSum <= sum) {
+      if (WEIGHTED_RANDOM_DEBUG)
+        std::cout << "[RNG::weightedRandom()] sampled index "
+                  << i
+                  << "("
+                  << "running sum = "
+                  << sum
+                  << ", sampled sum = "
+                  << sampledSum
+                  << std::endl;
+      return i;
+    }
+  }
+
+  return weights.size() - 1;
 }
 
-}
+}   /*  namespace RandomNumberGenerators  */
+
 #endif
diff --git a/src/libprojectM/Renderer/BeatDetect.cpp b/src/libprojectM/Renderer/BeatDetect.cpp
index 106b544..e7f79ea 100644
--- a/src/libprojectM/Renderer/BeatDetect.cpp
+++ b/src/libprojectM/Renderer/BeatDetect.cpp
@@ -21,11 +21,10 @@
 /**
  * Takes sound data from wherever and returns beat detection values
  * Uses statistical Energy-Based methods. Very simple
- * 
+ *
  * Some stuff was taken from Frederic Patin's beat-detection article,
  * you'll find it online
  */
-
 #include <stdlib.h>
 #include <stdio.h>
 
@@ -36,151 +35,153 @@
 #include <cmath>
 #include "BeatDetect.hpp"
 
-BeatDetect::BeatDetect(PCM *pcm) {
-  int x,y; 
+
+BeatDetect::BeatDetect (PCM *pcm)
+{
+  int x,y;
 
   this->pcm=pcm;
 
-  this->vol_instant=0;
-  this->vol_history=0;
+  this->vol_instant = 0;
+  this->vol_history = 0;
 
-  for (y=0;y<80;y++)
-    {
-      this->vol_buffer[y]=0;
-    }
-
-  this->beat_buffer_pos=0;
-
-  for (x=0;x<32;x++) {
-      this->beat_instant[x]=0;
-      this->beat_history[x]=0;
-      this->beat_val[x]=1.0;
-      this->beat_att[x]=1.0;
-      this->beat_variance[x]=0;
-      for (y=0;y<80;y++) {
-	    this->beat_buffer[x][y]=0;
-	    }
-    }
-
-    this->treb = 0;
-    this->mid = 0;
-    this->bass = 0;
-    this->vol_old = 0;
-    this->beat_sensitivity = 10.00;
-    this->treb_att = 0;
-    this->mid_att = 0;
-    this->bass_att = 0;
-    this->vol = 0;
-
-  
+  for (y = 0;  y < 80;  y++)
+  {
+    this->vol_buffer[y] = 0;
   }
 
-BeatDetect::~BeatDetect() 
+  this->beat_buffer_pos = 0;
+
+  for (x = 0;  x < 32;  x++) {
+    this->beat_instant[x] = 0;
+    this->beat_history[x] = 0;
+    this->beat_val[x] = 1.0;
+    this->beat_att[x] = 1.0;
+    this->beat_variance[x] = 0;
+    for (y = 0;  y < 80;  y++) {
+      this->beat_buffer[x][y] = 0;
+    }
+  }
+
+  this->treb = 0;
+  this->mid = 0;
+  this->bass = 0;
+  this->vol_old = 0;
+  this->beat_sensitivity = 10.00;
+  this->treb_att = 0;
+  this->mid_att = 0;
+  this->bass_att = 0;
+  this->vol = 0;
+}
+
+BeatDetect::~BeatDetect()
 {
 
 }
 
-void BeatDetect::reset() {
-  this->treb = 0;
-  this->mid = 0;
-  this->bass = 0;
-  this->treb_att = 0;
-  this->mid_att = 0;
-  this->bass_att = 0;
-  }
-
-void BeatDetect::detectFromSamples() {
-    vol_old = vol;
-    bass=0;mid=0;treb=0;
-
-    getBeatVals(pcm->pcmdataL,pcm->pcmdataR);
-  }
-
-void BeatDetect::getBeatVals( float *vdataL,float *vdataR ) {
-
-  int linear=0;
-  int x,y;
-  float temp2=0;
-
-  vol_instant=0;
-      for ( x=0;x<16;x++)
-	{
-	  
-	  beat_instant[x]=0;
-	  for ( y=linear*2;y<(linear+8+x)*2;y++)
-	    {
-	      beat_instant[x]+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/(8+x)); 
-//	      printf( "beat_instant[%d]: %f %f %f\n", x, beat_instant[x], vdataL[y], vdataR[y] );
-	      vol_instant+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/512.0);
-
-	    }
-//printf("1");	  
-	  linear=y/2;
-	  beat_history[x]-=(beat_buffer[x][beat_buffer_pos])*.0125;
-	  beat_buffer[x][beat_buffer_pos]=beat_instant[x];
-	  beat_history[x]+=(beat_instant[x])*.0125;
-	  
-	  beat_val[x]=(beat_instant[x])/(beat_history[x]);
-	  
-	  beat_att[x]+=(beat_instant[x])/(beat_history[x]);
-
-//printf("2\n");
- 	  
-	}
-//printf("b\n");      
-      vol_history-=(vol_buffer[beat_buffer_pos])*.0125;
-      vol_buffer[beat_buffer_pos]=vol_instant;
-      vol_history+=(vol_instant)*.0125;
-
-      mid=0;
-      for(x=1;x<10;x++)
-	{
-	 mid+=(beat_instant[x]);
-	  temp2+=(beat_history[x]);
-	 
-	}
-
-	 mid=mid/(1.5*temp2);
-	 temp2=0;
-	 treb=0;
- 	  for(x=10;x<16;x++)
-	    { 
-	      treb+=(beat_instant[x]);
-	      temp2+=(beat_history[x]);
-	    }
-//printf("c\n");
-	  treb=treb/(1.5*temp2);
-//	  *vol=vol_instant/(1.5*vol_history);
-	  vol=vol_instant/(1.5*vol_history);
-
-	  bass=(beat_instant[0])/(1.5*beat_history[0]);
-
-	  
-	  if ( projectM_isnan( treb ) ) {
-	    treb = 0.0;
-	  }
-	  if ( projectM_isnan( mid ) ) {
-	    mid = 0.0;
-	  }
-	  if ( projectM_isnan( bass ) ) {
-	    bass = 0.0;
-	  }
-	  treb_att=.6 * treb_att + .4 * treb;
-	  mid_att=.6 * mid_att + .4 * mid;
-	  bass_att=.6 * bass_att + .4 * bass;
-
-	  if(bass_att>100)bass_att=100;
-	  if(bass >100)bass=100;
-	  if(mid_att>100)mid_att=100;
-	  if(mid >100)mid=100;
-	  if(treb_att>100)treb_att=100;
-	  if(treb >100)treb=100;
-	  if(vol>100)vol=100;
-	  
-	   // *vol=(beat_instant[3])/(beat_history[3]);
-	  beat_buffer_pos++;
-	  if( beat_buffer_pos>79)beat_buffer_pos=0;
-	
+void
+BeatDetect::reset()
+{
+  this->treb      = 0;
+  this->mid       = 0;
+  this->bass      = 0;
+  this->treb_att  = 0;
+  this->mid_att   = 0;
+  this->bass_att  = 0;
 }
 
+void
+BeatDetect::detectFromSamples()
+{
+  vol_old = vol;
+  bass = 0;  mid = 0;  treb = 0;
 
+  getBeatVals (pcm->pcmdataL, pcm->pcmdataR);
+}
+
+void
+BeatDetect::getBeatVals (float *vdataL, float *vdataR)
+{
+  int   linear=0;
+  int   x,y;
+  float temp2=0;
+
+  vol_instant = 0;
+  for (x = 0;  x < 16;  x++)
+  {
+    beat_instant[x]=0;
+    for (y = linear * 2;  y < (linear + 8 + x) * 2;  y++)
+    {
+      beat_instant[x] += ((vdataL[y] * vdataL[y])
+                       + (vdataR[y] * vdataR[y])) * (1.0 / (8 + x));
+      //        printf ("beat_instant[%d]: %f %f %f\n", x, beat_instant[x], vdataL[y], vdataR[y]);
+      vol_instant += ((vdataL[y] * vdataL[y])
+                   + (vdataR[y] * vdataR[y])) * (1.0 / 512.0);
+
+    }
+    //printf ("1");
+    linear = y / 2;
+    beat_history[x] -= (beat_buffer[x][beat_buffer_pos])*.0125;
+    beat_buffer[x][beat_buffer_pos] = beat_instant[x];
+    beat_history[x] += (beat_instant[x]) * .0125;
+
+    beat_val[x] = (beat_instant[x]) / (beat_history[x]);
+
+    beat_att[x] += (beat_instant[x]) / (beat_history[x]);
+
+    //printf ("2\n");
+
+  }
+  //printf ("b\n");
+  vol_history -= (vol_buffer[beat_buffer_pos]) * .0125;
+  vol_buffer[beat_buffer_pos] = vol_instant;
+  vol_history += (vol_instant) * .0125;
+
+  mid = 0;
+  for (x = 1;  x < 10;  x++)
+  {
+    mid += (beat_instant[x]);
+    temp2 += (beat_history[x]);
+  }
+
+  mid = mid / (1.5 * temp2);
+  temp2 = 0;
+  treb = 0;
+  for (x = 10;  x < 16;  x++)
+  {
+    treb += (beat_instant[x]);
+    temp2 += (beat_history[x]);
+  }
+  //printf ("c\n");
+  treb = treb / (1.5 * temp2);
+  //    *vol=vol_instant/(1.5*vol_history);
+  vol = vol_instant / (1.5 * vol_history);
+
+  bass = (beat_instant[0]) / (1.5 * beat_history[0]);
+
+
+  if (projectM_isnan (treb)) {
+    treb = 0.0;
+  }
+  if (projectM_isnan (mid)) {
+    mid = 0.0;
+  }
+  if (projectM_isnan (bass)) {
+    bass = 0.0;
+  }
+  treb_att = .6 * treb_att + .4 * treb;
+  mid_att = .6 * mid_att + .4 * mid;
+  bass_att = .6 * bass_att + .4 * bass;
+
+  if (bass_att > 100) bass_att =100;
+  if (bass > 100)     bass = 100;
+  if (mid_att > 100)  mid_att = 100;
+  if (mid > 100)      mid = 100;
+  if (treb_att > 100) treb_att = 100;
+  if (treb > 100)     treb = 100;
+  if (vol > 100)      vol = 100;
+
+  // *vol=(beat_instant[3])/(beat_history[3]);
+  beat_buffer_pos++;
+  if (beat_buffer_pos > 79) beat_buffer_pos = 0;
+}
diff --git a/src/libprojectM/Renderer/BeatDetect.hpp b/src/libprojectM/Renderer/BeatDetect.hpp
index 4dc3881..5da9831 100644
--- a/src/libprojectM/Renderer/BeatDetect.hpp
+++ b/src/libprojectM/Renderer/BeatDetect.hpp
@@ -27,7 +27,6 @@
  * $Log$
  *
  */
-
 #ifndef _BEAT_DETECT_H
 #define _BEAT_DETECT_H
 
@@ -37,38 +36,39 @@
 
 class DLLEXPORT BeatDetect
 {
-	public:
-		float treb ;
-		float mid ;
-		float bass ;
-		float vol_old ;
-		float beat_sensitivity;
-		float treb_att ;
-		float mid_att ;
-		float bass_att ;
-		float vol;
+public:
+  float treb;
+  float mid;
+  float bass;
+  float vol_old;
+  float beat_sensitivity;
+  float treb_att;
+  float mid_att;
+  float bass_att;
+  float vol;
 
-		PCM *pcm;
+  PCM *pcm;
 
-		/** Methods */
-		BeatDetect(PCM *pcm);
-		~BeatDetect();
-		void initBeatDetect();
-		void reset();
-		void detectFromSamples();
-		void getBeatVals ( float *vdataL, float *vdataR );
-	private:
-		/** Vars */
-		float beat_buffer[32][80],
-		beat_instant[32],
-		beat_history[32];
-		float beat_val[32],
-		beat_att[32],
-		beat_variance[32];
-		int beat_buffer_pos;
-		float vol_buffer[80],
-		vol_instant,
-		vol_history;
+  /** Methods */
+  BeatDetect(PCM *pcm);
+  ~BeatDetect();
+  void initBeatDetect();
+  void reset();
+  void detectFromSamples();
+  void getBeatVals ( float *vdataL, float *vdataR );
+
+private:
+  /** Vars */
+  float beat_buffer[32][80],
+        beat_instant[32],
+        beat_history[32];
+  float beat_val[32],
+        beat_att[32],
+        beat_variance[32];
+  int   beat_buffer_pos;
+  float vol_buffer[80],
+        vol_instant,
+        vol_history;
 };
 
 #endif /** !_BEAT_DETECT_H */
diff --git a/src/libprojectM/Renderer/FBO.cpp b/src/libprojectM/Renderer/FBO.cpp
index fac2408..06aa4fd 100644
--- a/src/libprojectM/Renderer/FBO.cpp
+++ b/src/libprojectM/Renderer/FBO.cpp
@@ -23,8 +23,8 @@
  *
  * Render this methods
  */
-
 #include <stdio.h>
+#include <string.h>
 //#include <GL/gl.h>
 #include <iostream>
 #include "Common.hpp"
@@ -32,268 +32,309 @@
 
 
 
-RenderTarget::~RenderTarget() {
-
-
-	glDeleteTextures( 1, &this->textureID[0]);
+RenderTarget::~RenderTarget()
+{
+  glDeleteTextures (1, &this->textureID[0]);
 
 #ifdef USE_FBO
-	if (useFBO) 
-         {
-		glDeleteTextures( 1, &this->textureID[1] );
-		glDeleteRenderbuffersEXT(1,  &this->depthb[0]);
-		glDeleteFramebuffersEXT(1, &this->fbuffer[0]);
-		if(renderToTexture)
-		  {
-		    glDeleteTextures( 1, &this->textureID[2] );
-		    glDeleteRenderbuffersEXT(1,  &this->depthb[1]);
-		    glDeleteFramebuffersEXT(1, &this->fbuffer[1]);
-		  }
-         }
+  if (useFBO)
+  {
+    glDeleteTextures (1, &this->textureID[1]);
+    glDeleteRenderbuffers (1,  &this->depthb[0]);
+    glDeleteFramebuffers (1, &this->fbuffer[0]);
+    if (renderToTexture)
+    {
+      glDeleteTextures (1, &this->textureID[2]);
+      glDeleteRenderbuffers (1,  &this->depthb[1]);
+      glDeleteFramebuffers (1, &this->fbuffer[1]);
+    }
+  }
 #endif
-
 }
 
 GLuint RenderTarget::initRenderToTexture()
 {
 #ifdef USE_FBO
-
   if (this->useFBO==1)
-    {
-      this->renderToTexture=1;
-      
-      GLuint   fb2, depth_rb2;
-      glGenFramebuffersEXT(1, &fb2);
-      glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fb2 );
-      glGenRenderbuffersEXT(1, &depth_rb2);
-      glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, depth_rb2 );
-      
-      glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, this->texsize,this->texsize  );
-      glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb2 );         
-      this->fbuffer[1] = fb2;
-      this->depthb[1]=  depth_rb2;
-      glGenTextures(1, &this->textureID[2]);
-      glBindTexture(GL_TEXTURE_2D, this->textureID[2]); 
-      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-      glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, texsize, texsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
-      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-      glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, this->textureID[2], 0 );
-      return this->textureID[2];
-    }
-#endif 
-return -1;
-      
+  {
+    this->renderToTexture=1;
+
+    GLuint   fb2, depth_rb2;
+
+    glGenFramebuffers (1, &fb2);
+    glBindFramebuffer (GL_FRAMEBUFFER, fb2);
+    glGenRenderbuffers (1, &depth_rb2);
+    glBindRenderbuffer (GL_RENDERBUFFER, depth_rb2);
+
+    glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, this->texsize,this->texsize );
+    glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_rb2);
+    this->fbuffer[1] = fb2;
+    this->depthb[1]=  depth_rb2;
+    glGenTextures (1, &this->textureID[2]);
+    glBindTexture (GL_TEXTURE_2D, this->textureID[2]);
+    glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, texsize, texsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+#ifdef USE_GLES1
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+#else
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+#endif
+    glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, this->textureID[2], 0);
+    return this->textureID[2];
+  }
+#endif
+  return -1;
 }
 
 /** Creates new pbuffers */
-RenderTarget::RenderTarget(int texsize, int width, int height) : useFBO(false) {
+RenderTarget::RenderTarget (int texsize, int width, int height)
+  : useFBO (false)
+{
+  int mindim = 0;
+  int origtexsize = 0;
 
-   int mindim = 0;
-   int origtexsize = 0;
-
-   this->renderToTexture = 0;
-   this->texsize = texsize;
+  this->renderToTexture = 0;
+  this->texsize = texsize;
 
 #ifdef USE_FBO
-   glewInit();
-      // Forceably disable FBO if user requested it but the video card / driver lacks
-      // the appropraite frame buffer extension.
-      if (useFBO = glewIsSupported("GL_EXT_framebuffer_object"))
-	{	 
+  // Forcibly disable FBO if user requested it but the video card / driver lacks
+  // the appropraite frame buffer extension.
 
-	  GLuint   fb,  depth_rb, rgba_tex,  other_tex;
-	  glGenFramebuffersEXT(1, &fb);
-	  glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fb );
-	  
-	  glGenRenderbuffersEXT(1, &depth_rb);
-	  glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, depth_rb );
-	  glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, this->texsize,this->texsize  );
-	  glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb );
-	  this->fbuffer[0] = fb;
-	  this->depthb[0]=  depth_rb;
-	  
-	  glGenTextures(1, &other_tex);
-	  glBindTexture(GL_TEXTURE_2D,other_tex);
-	  glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, texsize, texsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
-	  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-	  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-	  //glGenerateMipmapEXT(GL_TEXTURE_2D);
-	  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-	  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-	  
-	  
-	  
-	  glGenTextures(1, &rgba_tex);
-	  glBindTexture(GL_TEXTURE_2D, rgba_tex); 
-	  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-	  glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, texsize, texsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
-	  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-	  //glGenerateMipmapEXT(GL_TEXTURE_2D);
-	  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-	  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-	  
-	  
-	  
-	  glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, rgba_tex, 0 );         
-	  this->textureID[0] = rgba_tex;
-	  this->textureID[1] = other_tex; 
-	  
-	  GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
-
-	  glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
-
-	  if (status == GL_FRAMEBUFFER_COMPLETE_EXT) {
-	    return;
-	  }	
-	  std::cerr << "[projecM] warning: FBO support not detected. Using fallback." << std::endl;
-	}
-
-#endif 
-
-// Can reach here via two code paths: 
-// (1) useFBO was set to false externally by cmake / system setting / etc.
-// (2) useFBO was true but forced to false as it failed to pass all the GLU extension checks.
-
-    /** Fallback pbuffer creation via teximage hack */
-    /** Check the texture size against the viewport size */
-    /** If the viewport is smaller, then we'll need to scale the texture size down */
-    /** If the viewport is larger, scale it up */
-    mindim = width < height ? width : height;
-    origtexsize = this->texsize;
-    this->texsize = nearestPower2( mindim, SCALE_MINIFY );
-        glGenTextures(1, &this->textureID[0] );
-
-        glBindTexture(GL_TEXTURE_2D, this->textureID[0] );
-        //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-        //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
-        glTexImage2D(GL_TEXTURE_2D,
-		    0,
-		    GL_RGB,
-		    this->texsize, this->texsize,
-		    0,
-		    GL_RGBA,
-		    GL_UNSIGNED_BYTE,
-		    NULL);
-      
-
-   
-    return;
-  }
-
-  void RenderTarget::fallbackRescale(int width, int height)
+#ifdef USE_GLES1
+  /*
+   * FBO support is never part of GLES1 core; check for extension.
+   */
+  useFBO = !!strstr ((char const *) glGetString (GL_EXTENSIONS),
+                     "GL_OES_framebuffer_object");
+#else
+  /*
+   * If GL 3.0 or later is in scope, then framebuffer object support is present
+   * by default, and we just use the user's preference.
+   */
   {
-	int mindim = width < height ? width : height;
-    int origtexsize = this->texsize;
-    this->texsize = nearestPower2( mindim, SCALE_MINIFY );
+    long        majorvers;
+    char const  *glvers;
+    char        *endptr;
 
-    if (origtexsize == texsize)
-      return;
-
-    /* Create the texture that will be bound to the render this */
-    /*
-
-        if ( this->texsize != origtexsize ) {
-
-            glDeleteTextures( 1, &this->textureID[0] );
-          }
-    */
-
-        glGenTextures(1, &this->textureID[0] );
-
-        glBindTexture(GL_TEXTURE_2D, this->textureID[0] );
-        //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-        //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
-        glTexImage2D(GL_TEXTURE_2D,
-		    0,
-		    GL_RGB,
-		    this->texsize, this->texsize,
-		    0,
-		    GL_RGBA,
-		    GL_UNSIGNED_BYTE,
-		    NULL);
-      
-
+    glvers = glGetString (GL_VERSION);
+    majorvers = strtol (glvers, &endptr, 10);
+    if (endptr == glvers  ||  *endptr != '.') {
+      /*  Unparseable version number; force extension check.  */
+      majorvers = 0;
+    }
+    if (majorvers < 3) {
+      /*  GL 3.0 not in scope; check for FBO support by extension.  */
+      useFBO = !!strstr ((char const *) glGetString (GL_EXTENSIONS),
+                         "GL_EXT_framebuffer_object");
+    }
   }
+#endif  /*  USE_GLES1  */
+
+  if (useFBO)
+  {
+    GLuint   fb,  depth_rb, rgba_tex,  other_tex;
+    glGenFramebuffers (1, &fb);
+    glBindFramebuffer (GL_FRAMEBUFFER, fb);
+
+    glGenRenderbuffers (1, &depth_rb);
+    glBindRenderbuffer (GL_RENDERBUFFER, depth_rb);
+    glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, this->texsize,this->texsize );
+    glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_rb);
+    this->fbuffer[0] = fb;
+    this->depthb[0]=  depth_rb;
+
+    glGenTextures (1, &other_tex);
+    glBindTexture (GL_TEXTURE_2D,other_tex);
+    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, texsize, texsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+    glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    //glGenerateMipmap (GL_TEXTURE_2D);
+#ifdef USE_GLES1
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+#else
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+#endif
+
+
+
+    glGenTextures (1, &rgba_tex);
+    glBindTexture (GL_TEXTURE_2D, rgba_tex);
+    glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, texsize, texsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    //glGenerateMipmap (GL_TEXTURE_2D);
+#ifdef USE_GLES1
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+#else
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+#endif
+
+
+
+    glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rgba_tex, 0);
+    this->textureID[0] = rgba_tex;
+    this->textureID[1] = other_tex;
+
+    GLenum status = glCheckFramebufferStatus (GL_FRAMEBUFFER);
+
+    glBindFramebuffer (GL_FRAMEBUFFER, 0);
+
+    if (status == GL_FRAMEBUFFER_COMPLETE) {
+      return;
+    }
+    std::cerr << "[projecM] warning: FBO support not detected. Using fallback." << std::endl;
+  }
+#endif  /*  USE_FBO  */
+
+  // Can reach here via two code paths:
+  // (1) useFBO was set to false externally by cmake / system setting / etc.
+  // (2) useFBO was true but forced to false as it failed to pass all the GLU extension checks.
+
+  /** Fallback pbuffer creation via teximage hack */
+  /** Check the texture size against the viewport size */
+  /** If the viewport is smaller, then we'll need to scale the texture size down */
+  /** If the viewport is larger, scale it up */
+  mindim = width < height ? width : height;
+  origtexsize = this->texsize;
+  this->texsize = nearestPower2 (mindim, SCALE_MINIFY);
+  glGenTextures (1, &this->textureID[0]);
+
+  glBindTexture (GL_TEXTURE_2D, this->textureID[0]);
+  //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+  //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+  glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+  glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+  glTexImage2D (GL_TEXTURE_2D,
+                0,
+                GL_RGBA,
+                this->texsize, this->texsize,
+                0,
+                GL_RGBA,
+                GL_UNSIGNED_BYTE,
+                NULL);
+
+  return;
+}
+
+void
+RenderTarget::fallbackRescale (int width, int height)
+{
+  int mindim = width < height ? width : height;
+  int origtexsize = this->texsize;
+
+  this->texsize = nearestPower2 (mindim, SCALE_MINIFY);
+
+  if (origtexsize == texsize)
+    return;
+
+  /* Create the texture that will be bound to the render this */
+  /*
+
+  if (this->texsize != origtexsize) {
+    glDeleteTextures (1, &this->textureID[0]);
+  }
+  */
+
+  glGenTextures (1, &this->textureID[0]);
+
+  glBindTexture (GL_TEXTURE_2D, this->textureID[0]);
+  //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+  //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+  glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+  glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+  glTexImage2D (GL_TEXTURE_2D,
+                0,
+                GL_RGBA,
+                this->texsize, this->texsize,
+                0,
+                GL_RGBA,
+                GL_UNSIGNED_BYTE,
+                NULL);
+}
 
 /** Destroys the pbuffer */
 
 /** Locks the pbuffer */
-void RenderTarget::lock() {
-
+void
+RenderTarget::lock()
+{
 #ifdef USE_FBO
-  if(this->useFBO)
-    { 
-      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, this->fbuffer[0]);     
-    }
+  if (this->useFBO)
+  {
+    glBindFramebuffer (GL_FRAMEBUFFER, this->fbuffer[0]);
+  }
 #endif
-    }
+}
 
 /** Unlocks the pbuffer */
-void RenderTarget::unlock() {
-
+void
+RenderTarget::unlock()
+{
 #ifdef USE_FBO
-  if(this->useFBO)
-    {
-      glBindTexture( GL_TEXTURE_2D, this->textureID[1] );
-      glCopyTexSubImage2D( GL_TEXTURE_2D,
-                         0, 0, 0, 0, 0, 
-                         this->texsize, this->texsize );
-      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-      return;
-    }
-#endif
-    /** Fallback texture path */
-    
-    glBindTexture( GL_TEXTURE_2D, this->textureID[0] );
-    
-	glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, this->texsize, this->texsize );
+  if (this->useFBO)
+  {
+    glBindTexture (GL_TEXTURE_2D, this->textureID[1]);
+    glCopyTexSubImage2D (GL_TEXTURE_2D,
+                         0, 0, 0, 0, 0,
+                         this->texsize, this->texsize);
+    glBindFramebuffer (GL_FRAMEBUFFER, 0);
+    return;
   }
+#endif
+  /** Fallback texture path */
 
-/** 
+  glBindTexture (GL_TEXTURE_2D, this->textureID[0]);
+
+  glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 0, 0, this->texsize, this->texsize);
+}
+
+/**
  * Calculates the nearest power of two to the given number using the
  * appropriate rule
  */
-int RenderTarget::nearestPower2( int value, TextureScale scaleRule ) {
+int
+RenderTarget::nearestPower2 (int value, TextureScale scaleRule)
+{
+  int x = value;
+  int power = 0;
 
-    int x = value;
-    int power = 0;
-
-    while ( ( x & 0x01 ) != 1 ) {
-        x >>= 1;
-      }
-
-    if ( x == 1 ) {
-        return value;
-      } else {
-        x = value;
-        while ( x != 0 ) {
-            x >>= 1;
-            power++;
-          }
-        switch ( scaleRule ) {
-            case SCALE_NEAREST:
-                if ( ( ( 1 << power ) - value ) <= ( value - ( 1 << ( power - 1 ) ) ) ) {
-                    return 1 << power;
-                  } else {
-                    return 1 << ( power - 1 );
-                  }
-            case SCALE_MAGNIFY:
-                return 1 << power;
-            case SCALE_MINIFY:
-                return 1 << ( power - 1 );
-            default:
-                break;
-          }
-      }
-    return 0;
+  while ((x & 0x01) != 1) {
+    x >>= 1;
   }
+
+  if (x == 1) {
+    return value;
+  } else {
+    x = value;
+    while (x != 0) {
+      x >>= 1;
+      power++;
+    }
+    switch (scaleRule) {
+    case SCALE_NEAREST:
+      if (((1 << power) - value) <= (value - (1 << (power - 1)))) {
+        return 1 << power;
+      } else {
+        return 1 << (power - 1);
+      }
+    case SCALE_MAGNIFY:
+      return 1 << power;
+    case SCALE_MINIFY:
+      return 1 << (power - 1);
+    default:
+      break;
+    }
+  }
+  return 0;
+}
diff --git a/src/libprojectM/Renderer/FBO.hpp b/src/libprojectM/Renderer/FBO.hpp
index e79954d..5eb90e3 100644
--- a/src/libprojectM/Renderer/FBO.hpp
+++ b/src/libprojectM/Renderer/FBO.hpp
@@ -24,18 +24,9 @@
  * Opaque render target
  *
  */
-
 #ifndef _RENDERTARGET_H
 #define _RENDERTARGET_H
 
-#ifdef USE_FBO
-#ifdef USE_NATIVE_GLEW
-#include "glew.h"
-#else
-#include <GL/glew.h>
-#endif
-#endif
-
 #ifdef MACOS
 #include <OpenGL/gl.h>
 #include <AGL/agl.h>
@@ -48,21 +39,28 @@
 #ifdef LINUX
 #ifdef USE_GLES1
 #include <GLES/gl.h>
+#include <GLES/glext.h>
 #else
 #include <GL/gl.h>
 #include <GL/glx.h>
 #endif
 #endif
 
-typedef enum { SCALE_NEAREST, SCALE_MAGNIFY, SCALE_MINIFY } TextureScale;
+#include "fbodefs.h"
+
+
+typedef enum {
+  SCALE_NEAREST,
+  SCALE_MAGNIFY,
+  SCALE_MINIFY
+} TextureScale;
+
 
 class RenderTarget {
-
-
 public:
-    /** Texture size */
-    int texsize;
-  
+  /** Texture size */
+  int texsize;
+
   int useFBO;
   int renderToTexture;
 
@@ -75,22 +73,21 @@
   int nearestPower2( int value, TextureScale scaleRule );
   void fallbackRescale(int width, int height);
 
-    /** Opaque pbuffer context and pbuffer */
-/*
+  /** Opaque pbuffer context and pbuffer */
+  /*
 #ifdef MACOS
-    void *origContext;
-    void *pbufferContext;
-    void *pbuffer;
+  void *origContext;
+  void *pbufferContext;
+  void *pbuffer;
 #endif
-*/
-    /** Render target texture ID for non-pbuffer systems */
-    GLuint textureID[3];
+  */
+  /** Render target texture ID for non-pbuffer systems */
+  GLuint textureID[3];
 #ifdef USE_FBO
-    GLuint fbuffer[2]; 
-    GLuint depthb[2];
+  GLuint fbuffer[2];
+  GLuint depthb[2];
 #endif
-  };
-
+};
 
 
 #endif /** !_RENDERTARGET_H */
diff --git a/src/libprojectM/Renderer/Filters.cpp b/src/libprojectM/Renderer/Filters.cpp
index 3e831f9..f064552 100644
--- a/src/libprojectM/Renderer/Filters.cpp
+++ b/src/libprojectM/Renderer/Filters.cpp
@@ -4,7 +4,6 @@
  *  Created on: Jun 18, 2008
  *      Author: pete
  */
-
 #include "Common.hpp"
 
 #ifdef USE_GLES1
@@ -21,78 +20,82 @@
 
 #include "Filters.hpp"
 
-void Brighten::Draw(RenderContext &context)
+
+void
+Brighten::Draw(RenderContext &context)
 {
-	float points[4][2] = {{-0.5, -0.5},
-				      {-0.5,  0.5},
-				      { 0.5,  0.5},
-				      { 0.5,  -0.5}};
+  float points[4][2] = {{-0.5, -0.5},
+                        {-0.5,  0.5},
+                        { 0.5,  0.5},
+                        { 0.5,  -0.5}};
 
-	glEnableClientState(GL_VERTEX_ARRAY);
-	glVertexPointer(2,GL_FLOAT,0,points);
+  glEnableClientState(GL_VERTEX_ARRAY);
+  glVertexPointer(2,GL_FLOAT,0,points);
 
-	glColor4f(1.0, 1.0, 1.0, 1.0);
-	glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
-	glDrawArrays(GL_TRIANGLE_FAN,0,4);
-	glBlendFunc(GL_ZERO, GL_DST_COLOR);
-	glDrawArrays(GL_TRIANGLE_FAN,0,4);
-	glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
-	glDrawArrays(GL_TRIANGLE_FAN,0,4);
-	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+  glColor4f(1.0, 1.0, 1.0, 1.0);
+  glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
+  glDrawArrays(GL_TRIANGLE_FAN,0,4);
+  glBlendFunc(GL_ZERO, GL_DST_COLOR);
+  glDrawArrays(GL_TRIANGLE_FAN,0,4);
+  glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
+  glDrawArrays(GL_TRIANGLE_FAN,0,4);
+  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
-	glDisableClientState(GL_VERTEX_ARRAY);
+  glDisableClientState(GL_VERTEX_ARRAY);
 }
 
-void Darken::Draw(RenderContext &context)
+void
+Darken::Draw(RenderContext &context)
 {
-	float points[4][2] = {{-0.5, -0.5},
-				      {-0.5,  0.5},
-				      { 0.5,  0.5},
-				      { 0.5,  -0.5}};
+  float points[4][2] = {{-0.5, -0.5},
+                        {-0.5,  0.5},
+                        { 0.5,  0.5},
+                        { 0.5,  -0.5}};
 
-		glEnableClientState(GL_VERTEX_ARRAY);
-		glVertexPointer(2,GL_FLOAT,0,points);
-		glColor4f(1.0, 1.0, 1.0, 1.0);
-		glBlendFunc(GL_ZERO, GL_DST_COLOR);
-		glDrawArrays(GL_TRIANGLE_FAN,0,4);
-		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-		glDisableClientState(GL_VERTEX_ARRAY);
+  glEnableClientState(GL_VERTEX_ARRAY);
+  glVertexPointer(2,GL_FLOAT,0,points);
+  glColor4f(1.0, 1.0, 1.0, 1.0);
+  glBlendFunc(GL_ZERO, GL_DST_COLOR);
+  glDrawArrays(GL_TRIANGLE_FAN,0,4);
+  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+  glDisableClientState(GL_VERTEX_ARRAY);
 }
 
-void Invert::Draw(RenderContext &context)
+void
+Invert::Draw(RenderContext &context)
 {
-	float points[4][2] = {{-0.5, -0.5},
-				      {-0.5,  0.5},
-				      { 0.5,  0.5},
-				      { 0.5,  -0.5}};
+  float points[4][2] = {{-0.5, -0.5},
+                        {-0.5,  0.5},
+                        { 0.5,  0.5},
+                        { 0.5,  -0.5}};
 
-		glEnableClientState(GL_VERTEX_ARRAY);
-		glVertexPointer(2,GL_FLOAT,0,points);
-		glColor4f(1.0, 1.0, 1.0, 1.0);
-		glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
-		glDrawArrays(GL_TRIANGLE_FAN,0,4);
-		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+  glEnableClientState(GL_VERTEX_ARRAY);
+  glVertexPointer(2,GL_FLOAT,0,points);
+  glColor4f(1.0, 1.0, 1.0, 1.0);
+  glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
+  glDrawArrays(GL_TRIANGLE_FAN,0,4);
+  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
-		glDisableClientState(GL_VERTEX_ARRAY);
+  glDisableClientState(GL_VERTEX_ARRAY);
 }
 
-void Solarize::Draw(RenderContext &context)
+void
+Solarize::Draw(RenderContext &context)
 {
-	float points[4][2] = {{-0.5, -0.5},
-					      {-0.5,  0.5},
-					      { 0.5,  0.5},
-					      { 0.5,  -0.5}};
+  float points[4][2] = {{-0.5, -0.5},
+                        {-0.5,  0.5},
+                        { 0.5,  0.5},
+                        { 0.5,  -0.5}};
 
-	glEnableClientState(GL_VERTEX_ARRAY);
-	glVertexPointer(2,GL_FLOAT,0,points);
+  glEnableClientState(GL_VERTEX_ARRAY);
+  glVertexPointer(2,GL_FLOAT,0,points);
 
-	glColor4f(1.0, 1.0, 1.0, 1.0);
-	glBlendFunc(GL_ZERO, GL_ONE_MINUS_DST_COLOR);
-	glDrawArrays(GL_TRIANGLE_FAN,0,4);
-	glBlendFunc(GL_DST_COLOR, GL_ONE);
-	glDrawArrays(GL_TRIANGLE_FAN,0,4);
-	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+  glColor4f(1.0, 1.0, 1.0, 1.0);
+  glBlendFunc(GL_ZERO, GL_ONE_MINUS_DST_COLOR);
+  glDrawArrays(GL_TRIANGLE_FAN,0,4);
+  glBlendFunc(GL_DST_COLOR, GL_ONE);
+  glDrawArrays(GL_TRIANGLE_FAN,0,4);
+  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
-	glDisableClientState(GL_VERTEX_ARRAY);
+  glDisableClientState(GL_VERTEX_ARRAY);
 }
-
diff --git a/src/libprojectM/Renderer/Filters.hpp b/src/libprojectM/Renderer/Filters.hpp
index 6ce64da..c27668a 100644
--- a/src/libprojectM/Renderer/Filters.hpp
+++ b/src/libprojectM/Renderer/Filters.hpp
@@ -4,38 +4,38 @@
  *  Created on: Jun 18, 2008
  *      Author: pete
  */
-
 #ifndef FILTERS_HPP_
 #define FILTERS_HPP_
 
 #include "Renderable.hpp"
 
+
 class Brighten : public RenderItem
 {
 public:
-	Brighten(){}
-	void Draw(RenderContext &context);
+  Brighten(){}
+  void Draw(RenderContext &context);
 };
 
 class Darken : public RenderItem
 {
 public:
-	Darken(){}
-	void Draw(RenderContext &context);
+  Darken(){}
+  void Draw(RenderContext &context);
 };
 
 class Invert : public RenderItem
 {
 public:
-	Invert(){}
-	void Draw(RenderContext &context);
+  Invert(){}
+  void Draw(RenderContext &context);
 };
 
 class Solarize : public RenderItem
 {
 public:
-	Solarize(){}
-	void Draw(RenderContext &context);
+  Solarize(){}
+  void Draw(RenderContext &context);
 };
 
 #endif /* FILTERS_HPP_ */
diff --git a/src/libprojectM/Renderer/MilkdropWaveform.cpp b/src/libprojectM/Renderer/MilkdropWaveform.cpp
index d93291e..d6859c9 100644
--- a/src/libprojectM/Renderer/MilkdropWaveform.cpp
+++ b/src/libprojectM/Renderer/MilkdropWaveform.cpp
@@ -7,10 +7,11 @@
 #include <iostream>
 
 #ifdef LINUX
+#ifdef USE_GLES1
+#include <GLES/gl.h>
+#else
 #include <GL/gl.h>
 #endif
-#ifdef WIN32
-#include "glew.h"
 #endif
 #ifdef __APPLE__
 #include <OpenGL/gl.h>
@@ -22,351 +23,366 @@
 #include "math.h"
 #include "BeatDetect.hpp"
 
-MilkdropWaveform::MilkdropWaveform(): RenderItem(),
-	x(0.5), y(0.5), r(1), g(0), b(0), a(1), mystery(0), mode(Line), scale(10), smoothing(0), rot(0), samples(0),modOpacityStart(0),modOpacityEnd(1),
-	modulateAlphaByVolume(false), maximizeColors(false), additive(false), dots(false), thick(false), loop(false) {}
 
-void MilkdropWaveform::Draw(RenderContext &context)
+MilkdropWaveform::MilkdropWaveform()
+  : RenderItem(),
+    x(0.5), y(0.5),
+    r(1), g(0), b(0), a(1),
+    mystery(0),
+    mode(Line),
+    scale(10),
+    smoothing(0),
+    rot(0),
+    samples(0),
+    modOpacityStart(0),
+    modOpacityEnd(1),
+    modulateAlphaByVolume(false),
+    maximizeColors(false),
+    additive(false),
+    dots(false),
+    thick(false),
+    loop(false)
+{}
+
+void
+MilkdropWaveform::Draw(RenderContext &context)
 {
-	  WaveformMath(context);
+  WaveformMath(context);
 
-	glMatrixMode( GL_MODELVIEW );
-		glPushMatrix();
-		glLoadIdentity();
+  glMatrixMode( GL_MODELVIEW );
+  glPushMatrix();
+  glLoadIdentity();
 
-		if(modulateAlphaByVolume) ModulateOpacityByVolume(context);
-		else temp_a = a;
-		MaximizeColors(context);
+  if (modulateAlphaByVolume)  ModulateOpacityByVolume(context);
+  else                        temp_a = a;
+  MaximizeColors(context);
 
-	#ifndef USE_GLES1
-		if(dots==1) glEnable(GL_LINE_STIPPLE);
-	#endif
+#ifndef USE_GLES1
+  if(dots==1) glEnable(GL_LINE_STIPPLE);
+#endif
 
-		//Thick wave drawing
-		if (thick==1)  glLineWidth( (context.texsize < 512 ) ? 2 : 2*context.texsize/512);
-		else glLineWidth( (context.texsize < 512 ) ? 1 : context.texsize/512);
+  //Thick wave drawing
+  if (thick == 1) glLineWidth( (context.texsize < 512 ) ? 2 : 2*context.texsize/512);
+  else            glLineWidth( (context.texsize < 512 ) ? 1 : context.texsize/512);
 
-		//Additive wave drawing (vice overwrite)
-		if (additive==1)glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-		else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+  //Additive wave drawing (vice overwrite)
+  if (additive == 1)  glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+  else                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
 
-		glTranslatef(.5, .5, 0);
-		glRotatef(rot, 0, 0, 1);
-		glScalef(aspectScale, 1.0, 1.0);
-		glTranslatef(-.5, -.5, 0);
+  glTranslatef(.5, .5, 0);
+  glRotatef(rot, 0, 0, 1);
+  glScalef(aspectScale, 1.0, 1.0);
+  glTranslatef(-.5, -.5, 0);
 
 
-		glEnableClientState(GL_VERTEX_ARRAY);
-		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-		glDisableClientState(GL_COLOR_ARRAY);
-		glVertexPointer(2,GL_FLOAT,0,wavearray);
+  glEnableClientState(GL_VERTEX_ARRAY);
+  glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+  glDisableClientState(GL_COLOR_ARRAY);
+  glVertexPointer(2,GL_FLOAT,0,wavearray);
 
-		if (loop)
-		  glDrawArrays(GL_LINE_LOOP,0,samples);
-		else
-		  glDrawArrays(GL_LINE_STRIP,0,samples);
+  if (loop)
+    glDrawArrays(GL_LINE_LOOP,0,samples);
+  else
+    glDrawArrays(GL_LINE_STRIP,0,samples);
 
 
-		if (two_waves)
-		  {
-		    glVertexPointer(2,GL_FLOAT,0,wavearray2);
-		    if (loop)
-		      glDrawArrays(GL_LINE_LOOP,0,samples);
-		    else
-		      glDrawArrays(GL_LINE_STRIP,0,samples);
-		  }
+  if (two_waves)
+  {
+    glVertexPointer(2,GL_FLOAT,0,wavearray2);
+    if (loop)
+      glDrawArrays(GL_LINE_LOOP,0,samples);
+    else
+      glDrawArrays(GL_LINE_STRIP,0,samples);
+  }
 
 
-	#ifndef USE_GLES1
-		if(dots==1) glDisable(GL_LINE_STIPPLE);
-	#endif
+#ifndef USE_GLES1
+  if(dots==1) glDisable(GL_LINE_STIPPLE);
+#endif
 
-		glPopMatrix();
+  glPopMatrix();
 }
 
-void MilkdropWaveform::ModulateOpacityByVolume(RenderContext &context)
+void
+MilkdropWaveform::ModulateOpacityByVolume(RenderContext &context)
 {
+  //modulate volume by opacity
+  //
+  //set an upper and lower bound and linearly
+  //calculate the opacity from 0=lower to 1=upper
+  //based on current volume
 
-	//modulate volume by opacity
-	//
-	//set an upper and lower bound and linearly
-	//calculate the opacity from 0=lower to 1=upper
-	//based on current volume
-
-	if (context.beatDetect->vol<= modOpacityStart)  temp_a=0.0;
-	 else if (context.beatDetect->vol>=modOpacityEnd) temp_a=a;
-	 else temp_a=a*((context.beatDetect->vol-modOpacityStart)/(modOpacityEnd-modOpacityStart));
-
+  if (context.beatDetect->vol<= modOpacityStart)
+    temp_a=0.0;
+  else if (context.beatDetect->vol>=modOpacityEnd)
+    temp_a=a;
+  else
+    temp_a=a*((context.beatDetect->vol-modOpacityStart)/(modOpacityEnd-modOpacityStart));
 }
 
-void MilkdropWaveform::MaximizeColors(RenderContext &context)
+void
+MilkdropWaveform::MaximizeColors(RenderContext &context)
 {
+  float wave_r_switch=0, wave_g_switch=0, wave_b_switch=0;
 
-	float wave_r_switch=0, wave_g_switch=0, wave_b_switch=0;
-	//wave color brightening
-	//
-	//forces max color value to 1.0 and scales
-	// the rest accordingly
-	if(mode==Blob2 || mode==Blob5)
-		switch(context.texsize)
-		{
-			case 256:  temp_a *= 0.07f; break;
-			case 512:  temp_a *= 0.09f; break;
-			case 1024: temp_a *= 0.11f; break;
-			case 2048: temp_a *= 0.13f; break;
-		}
-	else if(mode==Blob3)
-	{
-		switch(context.texsize)
-		{
-			case 256:  temp_a *= 0.075f; break;
-			case 512:  temp_a *= 0.15f; break;
-			case 1024: temp_a *= 0.22f; break;
-			case 2048: temp_a *= 0.33f; break;
-		}
-		temp_a*=1.3f;
-		temp_a*=std::pow(context.beatDetect->treb , 2.0f);
-	}
+  //wave color brightening
+  //
+  //forces max color value to 1.0 and scales
+  // the rest accordingly
+  if (mode==Blob2 || mode==Blob5)
+    switch(context.texsize)
+    {
+    case 256:  temp_a *= 0.07f; break;
+    case 512:  temp_a *= 0.09f; break;
+    case 1024: temp_a *= 0.11f; break;
+    case 2048: temp_a *= 0.13f; break;
+    }
+  else if(mode==Blob3)
+  {
+    switch(context.texsize)
+    {
+    case 256:  temp_a *= 0.075f; break;
+    case 512:  temp_a *= 0.15f; break;
+    case 1024: temp_a *= 0.22f; break;
+    case 2048: temp_a *= 0.33f; break;
+    }
+    temp_a*=1.3f;
+    temp_a*=std::pow(context.beatDetect->treb , 2.0f);
+  }
 
-	if (maximizeColors==true)
-	{
-		if(r>=g && r>=b)   //red brightest
-		{
-			wave_b_switch=b*(1/r);
-			wave_g_switch=g*(1/r);
-			wave_r_switch=1.0;
-		}
-		else if   (b>=g && b>=r)         //blue brightest
-		{
-			wave_r_switch=r*(1/b);
-			wave_g_switch=g*(1/b);
-			wave_b_switch=1.0;
-
-		}
-
-		else  if (g>=b && g>=r)         //green brightest
-		{
-			wave_b_switch=b*(1/g);
-			wave_r_switch=r*(1/g);
-			wave_g_switch=1.0;
-		}
+  if (maximizeColors==true)
+  {
+    if(r>=g && r>=b)   //red brightest
+    {
+      wave_b_switch=b*(1/r);
+      wave_g_switch=g*(1/r);
+      wave_r_switch=1.0;
+    }
+    else if   (b>=g && b>=r)         //blue brightest
+    {
+      wave_r_switch=r*(1/b);
+      wave_g_switch=g*(1/b);
+      wave_b_switch=1.0;
+    }
+    else  if (g>=b && g>=r)         //green brightest
+    {
+      wave_b_switch=b*(1/g);
+      wave_r_switch=r*(1/g);
+      wave_g_switch=1.0;
+    }
 
 
-		glColor4f(wave_r_switch, wave_g_switch, wave_b_switch, temp_a * masterAlpha);
-	}
-	else
-	{
-		glColor4f(r, g, b, temp_a * masterAlpha);
-	}
+    glColor4f(wave_r_switch, wave_g_switch, wave_b_switch, temp_a * masterAlpha);
+  }
+  else
+  {
+    glColor4f(r, g, b, temp_a * masterAlpha);
+  }
 }
 
 
-void MilkdropWaveform::WaveformMath(RenderContext &context)
+void
+MilkdropWaveform::WaveformMath(RenderContext &context)
 {
+  int   i;
+  float r, theta;
 
-	int i;
+  float offset;
 
-	float r, theta;
+  float wave_x_temp=0;
+  float wave_y_temp=0;
 
-	float offset;
-
-	float wave_x_temp=0;
-	float wave_y_temp=0;
-
-	float cos_rot;
-	float sin_rot;
-
-	offset=x-.5;
-    float temp_y;
-
-	two_waves = false;
-	loop = false;
-
-	switch(mode)
-	{
-
-		case Circle:
-		  {
- 		    loop = true;
-			rot =   0;
-			aspectScale=1.0;
-			temp_y=-1*(y-1.0);
+  float cos_rot;
+  float sin_rot;
 
 
-			samples = 0? 512-32 : context.beatDetect->pcm->numsamples;
+  offset=x-.5;
+  float temp_y;
 
-			float inv_nverts_minus_one = 1.0f/(float)(samples);
+  two_waves = false;
+  loop = false;
 
-	       float last_value = context.beatDetect->pcm->pcmdataR[samples-1]+context.beatDetect->pcm->pcmdataL[samples-1];
-			float first_value = context.beatDetect->pcm->pcmdataR[0]+context.beatDetect->pcm->pcmdataL[0];
-			float offset = first_value-last_value;
-
-			for ( int i=0;i<samples;i++)
-			{
-
-			  float value = context.beatDetect->pcm->pcmdataR[i]+context.beatDetect->pcm->pcmdataL[i];
-			  value += offset * (i/(float)samples);
-
-			  r=(0.5 + 0.4f*.12*value*scale + mystery)*.5;
-			  theta=i*inv_nverts_minus_one*6.28f + context.time*0.2f;
-
-			  wavearray[i][0]=(r*cos(theta)*(context.aspectCorrect? context.aspectRatio : 1.0)+x);
-			  wavearray[i][1]=(r*sin(theta)+temp_y);
-			}
-		  }
-
-			break;
-
-		case RadialBlob://circularly moving waveform
-
-			rot =   0;
-			aspectScale = context.aspectRatio;
-
-			temp_y=-1*(y-1.0);
-
-			samples = 512-32;
-			for ( int i=0;i<512-32;i++)
-			{
-				theta=context.beatDetect->pcm->pcmdataL[i+32]*0.06*scale * 1.57 + context.time*2.3;
-				r=(0.53 + 0.43*context.beatDetect->pcm->pcmdataR[i]*0.12*scale+ mystery)*.5;
-
-				wavearray[i][0]=(r*cos(theta)*(context.aspectCorrect ? context.aspectRatio : 1.0)+x);
-				wavearray[i][1]=(r*sin(theta)+temp_y);
-			}
-
-			break;
-
-		case Blob2://EXPERIMENTAL
-
-			temp_y=-1*(y-1.0);
-			rot =   0;
-			aspectScale =1.0;
-			samples = 512-32;
-
-			for ( int i=0;i<512-32;i++)
-			{
-				wavearray[i][0]=(context.beatDetect->pcm->pcmdataR[i]*scale*0.5*(context.aspectCorrect ? context.aspectRatio : 1.0) + x);
-				wavearray[i][1]=(context.beatDetect->pcm->pcmdataL[i+32]*scale*0.5 + temp_y);
-			}
-
-			break;
-
-		case Blob3://EXPERIMENTAL
-
-			temp_y=-1*(y-1.0);
-
-			rot =   0;
-			aspectScale =1.0;
-
-			samples = 512-32;
-
-			for ( int i=0;i<512-32;i++)
-			{
-				wavearray[i][0]=(context.beatDetect->pcm->pcmdataR[i] * scale*0.5 + x);
-				wavearray[i][1]=( (context.beatDetect->pcm->pcmdataL[i+32]*scale*0.5 + temp_y));
-			}
-
-			break;
-
-		case DerivativeLine://single x-axis derivative waveform
-		{
-			rot =-mystery*90;
-			aspectScale=1.0;
-
-			temp_y=-1*(y-1.0);
-
-			float w1 = 0.45f + 0.5f*(mystery*0.5f + 0.5f);
-			float w2 = 1.0f - w1;
-			float xx[512], yy[512];
-			samples = 512-32;
-
-			for (int i=0; i<512-32; i++)
-			{
-				xx[i] = -1.0f + 2.0f*(i/(512.0-32.0)) + x;
-				yy[i] =0.4* context.beatDetect->pcm->pcmdataL[i]*0.47f*scale + temp_y;
-				xx[i] += 0.4*context.beatDetect->pcm->pcmdataR[i]*0.44f*scale;
-
-				if (i>1)
-				{
-					xx[i] = xx[i]*w2 + w1*(xx[i-1]*2.0f - xx[i-2]);
-					yy[i] = yy[i]*w2 + w1*(yy[i-1]*2.0f - yy[i-2]);
-				}
-				wavearray[i][0]=xx[i];
-				wavearray[i][1]=yy[i];
-			}											   		}
-		break;
-
-		case Blob5://EXPERIMENTAL
-
-			rot = 0;
-			aspectScale =1.0;
-
-			temp_y=-1*(y-1.0);
-
-			cos_rot = cosf(context.time*0.3f);
-			sin_rot = sinf(context.time*0.3f);
-			samples = 512-32;
-
-			for ( int i=0;i<512-32;i++)
-			{
-				float x0 = (context.beatDetect->pcm->pcmdataR[i]*context.beatDetect->pcm->pcmdataL[i+32] + context.beatDetect->pcm->pcmdataL[i+32]*context.beatDetect->pcm->pcmdataR[i]);
-				float y0 = (context.beatDetect->pcm->pcmdataR[i]*context.beatDetect->pcm->pcmdataR[i] - context.beatDetect->pcm->pcmdataL[i+32]*context.beatDetect->pcm->pcmdataL[i+32]);
-				wavearray[i][0]=((x0*cos_rot - y0*sin_rot)*scale*0.5*(context.aspectCorrect ? context.aspectRatio : 1.0) + x);
-				wavearray[i][1]=( (x0*sin_rot + y0*cos_rot)*scale*0.5 + temp_y);
-			}
-			break;
-
-		case Line://single waveform
+  switch(mode)
+  {
+  case Circle:
+    {
+      loop = true;
+      rot =   0;
+      aspectScale=1.0;
+      temp_y=-1*(y-1.0);
 
 
-			wave_x_temp=-2*0.4142*(fabs(fabs(mystery)-.5)-.5);
+      samples = 0? 512-32 : context.beatDetect->pcm->numsamples;
 
-			rot = -mystery*90;
-			aspectScale =1.0+wave_x_temp;
-			wave_x_temp=-1*(x-1.0);
-			samples = 0 ? 512-32 : context.beatDetect->pcm->numsamples;
+      float inv_nverts_minus_one = 1.0f/(float)(samples);
 
-			for ( int i=0;i<  samples;i++)
-			{
+      float last_value = context.beatDetect->pcm->pcmdataR[samples-1]+context.beatDetect->pcm->pcmdataL[samples-1];
+      float first_value = context.beatDetect->pcm->pcmdataR[0]+context.beatDetect->pcm->pcmdataL[0];
+      float offset = first_value-last_value;
 
-				wavearray[i][0]=i/(float)  samples;
-				wavearray[i][1]=context.beatDetect->pcm->pcmdataR[i]*.04*scale+wave_x_temp;
+      for ( int i=0;i<samples;i++)
+      {
+        float value = context.beatDetect->pcm->pcmdataR[i]+context.beatDetect->pcm->pcmdataL[i];
+        value += offset * (i/(float)samples);
 
-			}
-			//	  printf("%f %f\n",renderTarget->texsize*wave_y_temp,wave_y_temp);
+        r=(0.5 + 0.4f*.12*value*scale + mystery)*.5;
+        theta=i*inv_nverts_minus_one*6.28f + context.time*0.2f;
 
-			break;
+        wavearray[i][0]=(r*cos(theta)*(context.aspectCorrect? context.aspectRatio : 1.0)+x);
+        wavearray[i][1]=(r*sin(theta)+temp_y);
+      }
+    }
 
-		case DoubleLine://dual waveforms
+    break;
+
+  case RadialBlob://circularly moving waveform
+
+    rot =   0;
+    aspectScale = context.aspectRatio;
+
+    temp_y=-1*(y-1.0);
+
+    samples = 512-32;
+    for ( int i=0;i<512-32;i++)
+    {
+      theta=context.beatDetect->pcm->pcmdataL[i+32]*0.06*scale * 1.57 + context.time*2.3;
+      r=(0.53 + 0.43*context.beatDetect->pcm->pcmdataR[i]*0.12*scale+ mystery)*.5;
+
+      wavearray[i][0]=(r*cos(theta)*(context.aspectCorrect ? context.aspectRatio : 1.0)+x);
+      wavearray[i][1]=(r*sin(theta)+temp_y);
+    }
+
+    break;
+
+  case Blob2://EXPERIMENTAL
+
+    temp_y=-1*(y-1.0);
+    rot =   0;
+    aspectScale =1.0;
+    samples = 512-32;
+
+    for ( int i=0;i<512-32;i++)
+    {
+      wavearray[i][0]=(context.beatDetect->pcm->pcmdataR[i]*scale*0.5*(context.aspectCorrect ? context.aspectRatio : 1.0) + x);
+      wavearray[i][1]=(context.beatDetect->pcm->pcmdataL[i+32]*scale*0.5 + temp_y);
+    }
+
+    break;
+
+  case Blob3://EXPERIMENTAL
+
+    temp_y=-1*(y-1.0);
+
+    rot =   0;
+    aspectScale =1.0;
+
+    samples = 512-32;
+
+    for ( int i=0;i<512-32;i++)
+    {
+      wavearray[i][0]=(context.beatDetect->pcm->pcmdataR[i] * scale*0.5 + x);
+      wavearray[i][1]=( (context.beatDetect->pcm->pcmdataL[i+32]*scale*0.5 + temp_y));
+    }
+
+    break;
+
+  case DerivativeLine://single x-axis derivative waveform
+    {
+      rot =-mystery*90;
+      aspectScale=1.0;
+
+      temp_y=-1*(y-1.0);
+
+      float w1 = 0.45f + 0.5f*(mystery*0.5f + 0.5f);
+      float w2 = 1.0f - w1;
+      float xx[512], yy[512];
+      samples = 512-32;
+
+      for (int i=0; i<512-32; i++)
+      {
+        xx[i] = -1.0f + 2.0f*(i/(512.0-32.0)) + x;
+        yy[i] =0.4* context.beatDetect->pcm->pcmdataL[i]*0.47f*scale + temp_y;
+        xx[i] += 0.4*context.beatDetect->pcm->pcmdataR[i]*0.44f*scale;
+
+        if (i>1)
+        {
+          xx[i] = xx[i]*w2 + w1*(xx[i-1]*2.0f - xx[i-2]);
+          yy[i] = yy[i]*w2 + w1*(yy[i-1]*2.0f - yy[i-2]);
+        }
+        wavearray[i][0]=xx[i];
+        wavearray[i][1]=yy[i];
+      }
+    }
+    break;
+
+  case Blob5://EXPERIMENTAL
+
+    rot = 0;
+    aspectScale =1.0;
+
+    temp_y=-1*(y-1.0);
+
+    cos_rot = cosf(context.time*0.3f);
+    sin_rot = sinf(context.time*0.3f);
+    samples = 512-32;
+
+    for ( int i=0;i<512-32;i++)
+    {
+      float x0 = (  context.beatDetect->pcm->pcmdataR[i] * context.beatDetect->pcm->pcmdataL[i + 32]
+                  + context.beatDetect->pcm->pcmdataL[i + 32] * context.beatDetect->pcm->pcmdataR[i]);
+      float y0 = (  context.beatDetect->pcm->pcmdataR[i] * context.beatDetect->pcm->pcmdataR[i]
+                  - context.beatDetect->pcm->pcmdataL[i + 32] * context.beatDetect->pcm->pcmdataL[i + 32]);
+      wavearray[i][0] = ((x0*cos_rot - y0*sin_rot)*scale*0.5*(context.aspectCorrect ? context.aspectRatio : 1.0) + x);
+      wavearray[i][1] = ( (x0*sin_rot + y0*cos_rot)*scale*0.5 + temp_y);
+    }
+    break;
+
+  case Line://single waveform
+
+    wave_x_temp=-2*0.4142*(fabs(fabs(mystery)-.5)-.5);
+
+    rot = -mystery*90;
+    aspectScale =1.0+wave_x_temp;
+    wave_x_temp=-1*(x-1.0);
+    samples = 0 ? 512-32 : context.beatDetect->pcm->numsamples;
+
+    for ( int i=0;i<  samples;i++)
+    {
+      wavearray[i][0]=i/(float)  samples;
+      wavearray[i][1]=context.beatDetect->pcm->pcmdataR[i]*.04*scale+wave_x_temp;
+    }
+    //    printf("%f %f\n",renderTarget->texsize*wave_y_temp,wave_y_temp);
+
+    break;
+
+  case DoubleLine://dual waveforms
+
+    wave_x_temp=-2*0.4142*(fabs(fabs(mystery)-.5)-.5);
+
+    rot = -mystery*90;
+    aspectScale =1.0+wave_x_temp;
 
 
-			wave_x_temp=-2*0.4142*(fabs(fabs(mystery)-.5)-.5);
+    samples = 0 ? 512-32 : context.beatDetect->pcm->numsamples;
+    two_waves = true;
 
-			rot = -mystery*90;
-			aspectScale =1.0+wave_x_temp;
+    double y_adj = y*y*.5;
 
+    wave_y_temp=-1*(x-1);
 
-			samples = 0 ? 512-32 : context.beatDetect->pcm->numsamples;
-			two_waves = true;
+    for ( int i=0;i<samples;i++)
+    {
+      wavearray[i][0]=i/((float)  samples);
+      wavearray[i][1]= context.beatDetect->pcm->pcmdataL[i]*.04*scale+(wave_y_temp+y_adj);
+    }
 
-			double y_adj = y*y*.5;
+    for ( int i=0;i<samples;i++)
+    {
+      wavearray2[i][0]=i/((float)  samples);
+      wavearray2[i][1]=context.beatDetect->pcm->pcmdataR[i]*.04*scale+(wave_y_temp-y_adj);
+    }
 
-			wave_y_temp=-1*(x-1);
-
-			for ( int i=0;i<samples;i++)
-			{
-				wavearray[i][0]=i/((float)  samples);
-				wavearray[i][1]= context.beatDetect->pcm->pcmdataL[i]*.04*scale+(wave_y_temp+y_adj);
-			}
-
-			for ( int i=0;i<samples;i++)
-			{
-				wavearray2[i][0]=i/((float)  samples);
-				wavearray2[i][1]=context.beatDetect->pcm->pcmdataR[i]*.04*scale+(wave_y_temp-y_adj);
-			}
-
-			break;
-
-	}
+    break;
+  }
 }
diff --git a/src/libprojectM/Renderer/MilkdropWaveform.hpp b/src/libprojectM/Renderer/MilkdropWaveform.hpp
index cdafd93..13a499b 100644
--- a/src/libprojectM/Renderer/MilkdropWaveform.hpp
+++ b/src/libprojectM/Renderer/MilkdropWaveform.hpp
@@ -4,62 +4,68 @@
  *  Created on: Jun 25, 2008
  *      Author: pete
  */
-
 #ifndef MILKDROPWAVEFORM_HPP_
 #define MILKDROPWAVEFORM_HPP_
 
 #include "Renderable.hpp"
 
+
 enum MilkdropWaveformMode
-	{
-	  Circle=0, RadialBlob, Blob2, Blob3, DerivativeLine, Blob5, Line, DoubleLine
-	};
+{
+  Circle=0,
+  RadialBlob,
+  Blob2,
+  Blob3,
+  DerivativeLine,
+  Blob5,
+  Line,
+  DoubleLine
+};
 
 
 class MilkdropWaveform : public RenderItem
 {
 public:
+  float x;
+  float y;
 
+  float r;
+  float g;
+  float b;
+  float a;
 
-	float x;
-	float y;
+  float mystery;
 
-	float r;
-	float g;
-	float b;
-	float a;
+  MilkdropWaveformMode mode;
 
-	float mystery;
+  bool  additive;
+  bool  dots;
+  bool  thick;
+  bool  modulateAlphaByVolume;
+  bool  maximizeColors;
+  float scale;
+  float smoothing;
 
-    MilkdropWaveformMode mode;
+  MilkdropWaveform();
+  void Draw(RenderContext &context);
 
-	bool additive;
-	bool dots;
-	bool thick;
-	bool modulateAlphaByVolume;
-	bool maximizeColors;
-	float scale;
-	float smoothing;
-
-	MilkdropWaveform();
-	void Draw(RenderContext &context);
-
-	float modOpacityStart;
-	float modOpacityEnd;
+  float modOpacityStart;
+  float modOpacityEnd;
 
 private:
-	float temp_a;
-	float rot;
-	float aspectScale;
-	int samples;
-	bool two_waves;
-	bool loop;
-	float wavearray[2048][2];
-	float wavearray2[2048][2];
+  float temp_a;
+  float rot;
+  float aspectScale;
+  int   samples;
+  bool  two_waves;
+  bool  loop;
+  float wavearray[2048][2];
+  float wavearray2[2048][2];
 
-	void MaximizeColors(RenderContext &context);
-	void ModulateOpacityByVolume(RenderContext &context);
-	void WaveformMath(RenderContext &context);
+  void MaximizeColors(RenderContext &context);
+  void ModulateOpacityByVolume(RenderContext &context);
+  void WaveformMath(RenderContext &context);
 
 };
+
 #endif /* MILKDROPWAVEFORM_HPP_ */
diff --git a/src/libprojectM/Renderer/PerPixelMesh.cpp b/src/libprojectM/Renderer/PerPixelMesh.cpp
index c378133..1b89f0c 100644
--- a/src/libprojectM/Renderer/PerPixelMesh.cpp
+++ b/src/libprojectM/Renderer/PerPixelMesh.cpp
@@ -4,45 +4,49 @@
 #include "omptl/omptl"
 #include "omptl/omptl_algorithm"
 
-PerPixelMesh::PerPixelMesh(int width, int height) : width(width), height(height), size (width * height),
-		p(width * height, PixelPoint(0,0)),
-		p_original(width * height, PixelPoint(0,0)),
-		identity(width * height, PerPixelContext(0,0,0,0,0,0))
-		{
-		for (int j=0;j<height;j++)
-			for(int i=0;i<width;i++)
-			{
-				int index = j * width + i;
 
-						float xval=i/(float)(width-1);
-						float yval=-((j/(float)(height-1))-1);
-
-						p[index].x = xval;
-						p[index].y = yval;
-
-						p_original[index].x = xval;
-						p_original[index].y = yval;
-
-						identity[index].x= xval;
-						identity[index].y= yval;
-
-						//identity[index].x= (xval-.5)*2;
-						//identity[index].y= (yval-.5)*2;
-
-						identity[index].i= i;
-						identity[index].j= j;
-
-						identity[index].rad=hypot ( ( xval-.5 ) *2, ( yval-.5 ) *2 ) * .7071067;
-						identity[index].theta=atan2 ( ( yval-.5 ) *2 ,  ( xval-.5 ) *2  );
-			}
-		}
-
-void PerPixelMesh::Reset()
+PerPixelMesh::PerPixelMesh (int width, int height)
+  : width(width), height(height),
+    size (width * height),
+    p(width * height, PixelPoint(0,0)),
+    p_original(width * height, PixelPoint(0,0)),
+    identity(width * height, PerPixelContext(0,0,0,0,0,0))
 {
-	omptl::copy(p_original.begin(), p_original.end(), p.begin());
+  for (int j = 0;  j < height;  j++)
+    for (int i = 0;  i < width;  i++)
+    {
+      int index = j * width + i;
+
+      float xval = i / (float) (width - 1);
+      float yval = -((j / (float) (height - 1)) - 1);
+
+      p[index].x = xval;
+      p[index].y = yval;
+
+      p_original[index].x = xval;
+      p_original[index].y = yval;
+
+      identity[index].x= xval;
+      identity[index].y= yval;
+
+      //identity[index].x= (xval-.5)*2;
+      //identity[index].y= (yval-.5)*2;
+
+      identity[index].i= i;
+      identity[index].j= j;
+
+      identity[index].rad=hypot ( ( xval-.5 ) *2, ( yval-.5 ) *2 ) * .7071067;
+      identity[index].theta=atan2 ( ( yval-.5 ) *2 ,  ( xval-.5 ) *2  );
+    }
+}
+
+void
+PerPixelMesh::Reset()
+{
+  omptl::copy(p_original.begin(), p_original.end(), p.begin());
 }
 
 PixelPoint::PixelPoint(float x, float y)
-	: x(x), y(y) {}
+  : x(x), y(y) {}
 PerPixelContext::PerPixelContext(float x, float y, float rad, float theta, int i, int j)
-	: x(x), y(y), rad(rad), theta(theta), i(i), j(j) {}
+  : x(x), y(y), rad(rad), theta(theta), i(i), j(j) {}
diff --git a/src/libprojectM/Renderer/PerPixelMesh.hpp b/src/libprojectM/Renderer/PerPixelMesh.hpp
index f37a2b1..3b47a09 100644
--- a/src/libprojectM/Renderer/PerPixelMesh.hpp
+++ b/src/libprojectM/Renderer/PerPixelMesh.hpp
@@ -3,43 +3,43 @@
 
 #include <vector>
 
+
 struct PixelPoint
 {
-	float x;
-	float y;
+  float x;
+  float y;
 
-	PixelPoint(float x, float y);
+  PixelPoint(float x, float y);
 };
 
 struct PerPixelContext
 {
-	float x;
-	float y;
-	float rad;
-	float theta;
+  float x;
+  float y;
+  float rad;
+  float theta;
 
-	int i;
-	int j;
+  int i;
+  int j;
 
-	PerPixelContext(float x, float y, float rad, float theta, int i, int j);
+  PerPixelContext(float x, float y, float rad, float theta, int i, int j);
 };
 
 class PerPixelMesh
 {
 public:
-	int width;
-	int height;
-	int size;
+  int width;
+  int height;
+  int size;
 
-	std::vector<PixelPoint> p;
-	std::vector<PixelPoint> p_original;
-	std::vector<PerPixelContext> identity;
+  std::vector<PixelPoint> p;
+  std::vector<PixelPoint> p_original;
+  std::vector<PerPixelContext> identity;
 
-	PerPixelMesh(int width, int height);
+  PerPixelMesh(int width, int height);
 
-	void Reset();
+  void Reset();
 };
 
 
-
 #endif
diff --git a/src/libprojectM/Renderer/PerlinNoise.cpp b/src/libprojectM/Renderer/PerlinNoise.cpp
index a6bda55..2fefa2b 100644
--- a/src/libprojectM/Renderer/PerlinNoise.cpp
+++ b/src/libprojectM/Renderer/PerlinNoise.cpp
@@ -4,50 +4,50 @@
  *  Created on: Jul 11, 2008
  *      Author: pete
  */
-
 #include "PerlinNoise.hpp"
 #include <iostream>
 #include <stdlib.h>
 
+
 PerlinNoise::PerlinNoise()
 {
-	for (int x = 0; x < 256;x++)
-		for (int y = 0; y < 256;y++)
-			noise_lq[x][y] = noise(x , y);
+  for (int x = 0; x < 256;x++)
+    for (int y = 0; y < 256;y++)
+      noise_lq[x][y] = noise(x , y);
 
-	for (int x = 0; x < 32;x++)
-		for (int y = 0; y < 32;y++)
-			noise_lq_lite[x][y] = noise(4*x,16*y);
+  for (int x = 0; x < 32;x++)
+    for (int y = 0; y < 32;y++)
+      noise_lq_lite[x][y] = noise(4*x,16*y);
 
-	for (int x = 0; x < 256;x++)
-		for (int y = 0; y < 256;y++)
-			noise_mq[x][y] = InterpolatedNoise((float)x/(float)2.0,(float)y/(float)2.0);
+  for (int x = 0; x < 256;x++)
+    for (int y = 0; y < 256;y++)
+      noise_mq[x][y] = InterpolatedNoise((float)x/(float)2.0,(float)y/(float)2.0);
 
-	for (int x = 0; x < 256;x++)
-		for (int y = 0; y < 256;y++)
-			noise_hq[x][y] = InterpolatedNoise((float)x/(float)3.0,(float)y/(float)3.0);
+  for (int x = 0; x < 256;x++)
+    for (int y = 0; y < 256;y++)
+      noise_hq[x][y] = InterpolatedNoise((float)x/(float)3.0,(float)y/(float)3.0);
 
-	for (int x = 0; x < 32;x++)
-		for (int y = 0; y < 32;y++)
-			for (int z = 0; z < 32;z++)
-				noise_lq_vol[x][y][z] = noise(x,y,z);
+  for (int x = 0; x < 32;x++)
+    for (int y = 0; y < 32;y++)
+      for (int z = 0; z < 32;z++)
+        noise_lq_vol[x][y][z] = noise(x,y,z);
 
-	for (int x = 0; x < 32;x++)
-		for (int y = 0; y < 32;y++)
-			for (int z = 0; z < 32;z++)
-				noise_hq_vol[x][y][z] = noise(x,y,z);//perlin_noise_3d(x,y,z,6121,7,seed3,0.5,64);
+  for (int x = 0; x < 32;x++)
+    for (int y = 0; y < 32;y++)
+      for (int z = 0; z < 32;z++)
+        noise_hq_vol[x][y][z] = noise(x,y,z);//perlin_noise_3d(x,y,z,6121,7,seed3,0.5,64);
 
-	int seed = rand()%1000;
+  int seed = rand()%1000;
 
-	int size = 512;
-	int octaves = sqrt((double)size);
+  int size = 512;
+  int octaves = sqrt((double)size);
 
-		for (int x = 0; x < size;x++)
-			for (int y = 0; y < size;y++)
-				noise_perlin[x][y] = perlin_noise_2d(x,y,6321,octaves,seed,0.5,size/4);
+    for (int x = 0; x < size;x++)
+      for (int y = 0; y < size;y++)
+        noise_perlin[x][y] = perlin_noise_2d(x,y,6321,octaves,seed,0.5,size/4);
 }
 
 PerlinNoise::~PerlinNoise()
 {
-	// TODO Auto-generated destructor stub
+  // TODO Auto-generated destructor stub
 }
diff --git a/src/libprojectM/Renderer/PerlinNoise.hpp b/src/libprojectM/Renderer/PerlinNoise.hpp
index e1193d7..fc77808 100644
--- a/src/libprojectM/Renderer/PerlinNoise.hpp
+++ b/src/libprojectM/Renderer/PerlinNoise.hpp
@@ -10,232 +10,227 @@
 
 #include <math.h>
 
+
 class PerlinNoise
 {
 public:
-
-	float noise_lq[256][256];
-	float noise_lq_lite[32][32];
-	float noise_mq[256][256];
-	float noise_hq[256][256];
-	float noise_perlin[512][512];
-	float noise_lq_vol[32][32][32];
-	float noise_hq_vol[32][32][32];
+  float noise_lq[256][256];
+  float noise_lq_lite[32][32];
+  float noise_mq[256][256];
+  float noise_hq[256][256];
+  float noise_perlin[512][512];
+  float noise_lq_vol[32][32][32];
+  float noise_hq_vol[32][32][32];
 
 
-	PerlinNoise();
-	virtual ~PerlinNoise();
+  PerlinNoise();
+  virtual ~PerlinNoise();
 
 private:
 
-	static inline float noise( int x)
-	{
-	    x = (x<<13)^x;
-	    return (((x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 2147483648.0);
-	   }
+  static inline float noise( int x)
+  {
+    x = (x<<13)^x;
+    return (((x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 2147483648.0);
+  }
 
-	static inline float noise(int x, int y)
-	{
-		 int n = x + y * 57;
-		 return noise(n);
-	}
+  static inline float noise(int x, int y)
+  {
+    int n = x + y * 57;
+    return noise(n);
+  }
 
-	static inline float noise(int x, int y, int z)
-	{
-		 int n = x + y * 57 + z * 141;
-		 return noise(n);
-	}
+  static inline float noise(int x, int y, int z)
+  {
+    int n = x + y * 57 + z * 141;
+    return noise(n);
+  }
 
-	static inline float cos_interp(float a, float b, float x)
-	{
-		float ft = x * 3.1415927;
-		float f = (1 - cos(ft)) * .5;
+  static inline float cos_interp(float a, float b, float x)
+  {
+    float ft = x * 3.1415927;
+    float f = (1 - cos(ft)) * .5;
 
-		return  a*(1-f) + b*f;
-	}
+    return  a*(1-f) + b*f;
+  }
 
-	static inline float cubic_interp(float v0, float v1, float v2, float v3, float x)
-	{
-		float P = (v3 - v2) - (v0 - v1);
-		float Q = (v0 - v1) - P;
-		float R = v2 - v0;
+  static inline float cubic_interp(float v0, float v1, float v2, float v3, float x)
+  {
+    float P = (v3 - v2) - (v0 - v1);
+    float Q = (v0 - v1) - P;
+    float R = v2 - v0;
 
-		return P*pow(x,3) + Q * pow(x,2) + R*x + v1;
-	}
+    return P*pow(x,3) + Q * pow(x,2) + R*x + v1;
+  }
 
-	static inline float InterpolatedNoise(float x, float y)
-	{
-		int integer_X = int(x);
-		float fractional_X = x - integer_X;
+  static inline float InterpolatedNoise(float x, float y)
+  {
+    int integer_X = int(x);
+    float fractional_X = x - integer_X;
 
-		int integer_Y = int(y);
-		float fractional_Y = y - integer_Y;
+    int integer_Y = int(y);
+    float fractional_Y = y - integer_Y;
 
-		float a0 = noise(integer_X - 1,      integer_Y - 1);
-		float a1 = noise(integer_X,          integer_Y - 1);
-		float a2 = noise(integer_X + 1,      integer_Y - 1);
-		float a3 = noise(integer_X + 2,      integer_Y - 1);
+    float a0 = noise(integer_X - 1,      integer_Y - 1);
+    float a1 = noise(integer_X,          integer_Y - 1);
+    float a2 = noise(integer_X + 1,      integer_Y - 1);
+    float a3 = noise(integer_X + 2,      integer_Y - 1);
 
-		float x0 = noise(integer_X - 1,      integer_Y);
-		float x1 = noise(integer_X,          integer_Y);
-		float x2 = noise(integer_X + 1,      integer_Y);
-		float x3 = noise(integer_X + 2,      integer_Y);
+    float x0 = noise(integer_X - 1,      integer_Y);
+    float x1 = noise(integer_X,          integer_Y);
+    float x2 = noise(integer_X + 1,      integer_Y);
+    float x3 = noise(integer_X + 2,      integer_Y);
 
-		float y0 = noise(integer_X + 0,   	 integer_Y + 1);
-		float y1 = noise(integer_X,     	 integer_Y + 1);
-		float y2 = noise(integer_X + 1, 	 integer_Y + 1);
-		float y3 = noise(integer_X + 2, 	 integer_Y + 1);
+    float y0 = noise(integer_X + 0,      integer_Y + 1);
+    float y1 = noise(integer_X,        integer_Y + 1);
+    float y2 = noise(integer_X + 1,    integer_Y + 1);
+    float y3 = noise(integer_X + 2,    integer_Y + 1);
 
-		float b0 = noise(integer_X - 1,      integer_Y + 2);
-		float b1 = noise(integer_X,          integer_Y + 2);
-		float b2 = noise(integer_X + 1,      integer_Y + 2);
-		float b3 = noise(integer_X + 2,      integer_Y + 2);
+    float b0 = noise(integer_X - 1,      integer_Y + 2);
+    float b1 = noise(integer_X,          integer_Y + 2);
+    float b2 = noise(integer_X + 1,      integer_Y + 2);
+    float b3 = noise(integer_X + 2,      integer_Y + 2);
 
-		float i0 = cubic_interp(a0 , a1, a2, a3, fractional_X);
-		float i1 = cubic_interp(x0 , x1, x2, x3, fractional_X);
-		float i2 = cubic_interp(y0 , y1, y2, y3, fractional_X);
-		float i3 = cubic_interp(b0 , b1, b2, b3, fractional_X);
+    float i0 = cubic_interp(a0 , a1, a2, a3, fractional_X);
+    float i1 = cubic_interp(x0 , x1, x2, x3, fractional_X);
+    float i2 = cubic_interp(y0 , y1, y2, y3, fractional_X);
+    float i3 = cubic_interp(b0 , b1, b2, b3, fractional_X);
 
-		return cubic_interp(i0, i1 , i2 , i3, fractional_Y);
+    return cubic_interp(i0, i1 , i2 , i3, fractional_Y);
 
-	}
+  }
 
-	static inline float perlin_octave_2d(float x,float y, int width, int seed, float period)
-	{
+  static inline float perlin_octave_2d(float x,float y, int width, int seed, float period)
+  {
+    float freq=1/(float)(period);
 
-	           float freq=1/(float)(period);
+    int num=(int)(width*freq);
+    int step_x=(int)(x*freq);