More JS cleanup and fixes