Did some code cleanup and clarification