More refactoring, splitting javascript into seperate files