Cleanup, optimizations

- Improvements via using Webstorm JSLint
  - whitespace
  - var declarations
  - correcting (top down) order of methods in code so they are available to other methods calling them
  - correcting jQuery duplicate selectors
  - minor optimizations