error checking and site.js cleanup