Fixed a lot of javascript typos and bugs