Tidy up script and minify