fix some bugs in JS compiler