Refactor javascriptgenerator (WIP)