JS bugfixes and upgrades