Removing unused code

In an attempt to clean up the codebase and to make enforcing the `unused` option of JSHint a step closer. This PR removes unused code/variables and fixes minor code style issues.