Code Refactor & Comments

Rearranged the code to make it more manageable & efficient. Added in
more comments describing each section.