Shrinking compile functions
Finished refactor to JavaScript