Refactor: rename and document some functions
Refactor main loop
Merge pull request #28 from mickboldon/refactor

Refactor