Reformat code
Fix framerate issues
Refactored code to be in a different javascript file