Reindented alot of the main file.
Made all the tabbing consistant
Replace a block of stuff that could of just been in a loop
Remove uses of alert, Paving some of the way for a node module
Merge pull request #49 from benjojo/CodeCleanup

Code cleanup