Adding docco for documentation generation
Adding documentation and cleaning up the code a little for readability