Many tweaks/updates to javascript