Cleaning up the syntax. Added semi colons to a lot of the code etc.