JS cleanup: avoidance of 'bad parts' and removing some commented out code.