Code Cleanup

Added comments and cleaned up miscellaneous code