Cleaned up some code, commented.