Some attempts to simplify the generated js code.