Cleaned up some code to pass JSHint