Refactored some code and removed comments.