Fixed some JS stuff and a few other bugs