cherry pick 14fcf5c from Sophist-UK for js debug
cleanup
more cleanup