Removed some console statements and refactored some code.