Comments, cleaned up code

Added more comments, formatted code, removed log statements