Updated comments and cleaned up/refactored code.