Overall code cleanup

* Removed the need for a double function call on define
* Improved JSHint support
* Cleaned up var definitions to top of function call