Cleaned up some code and comments