Reorganize code to enable Closure Compiler advanced optimizations