A lot of work to get generalized behaviour between generated js code.