* Clean up code by using helper functions where possible
* Add some function documentation