Added comments. Cleaned up some code.