Cleans up some code, includes some new comments