fix a few js bugs