Fix bugs in Compile_to_JS function