Commented more code and refactored a few things