Commented code and refactored

Commented all steps, cleaned up variable names, and reordered some of
the steps to be more intuitive