Commented, cleaned up some code