Javascript improvements and whitespace changes