compiler: js: sundry improvements to JS generated code