Changes to run on Linux

Changes to remove the Windows specific portions of the code and allow running on Linux (tested on Ubuntu 14.04).

Also a few fixes;
 - Fixed an infinate loop if not set up correctly
 - Fixed use of global temp dir, could cause concurrency issues
 - Commented out some incomplete code that was stopping the latest version functioning