Refactored code to make it a little more modular. I think it is nicer now.
Made some additional aesthetic changes [refactor]