Cleanup: Move all code into top-level 'use strict' func, fix JSLint warnings (hoisted vars, etc.) and cleanup indentation