Cleaned up code to run properly on linux.