Js fixups

Fixes for all the breakage due to namespacing of config vars, and various JS changes...

I haven't quite finished testing all this yet, but I'm putting here as a starting point for you to review and test independently.