Fix some js bugs