major refactoring. Fixed some JSHint Errors and tab indentation