Complete rewrite using uglify-js2 and resolve.