Refactor to clean up comments and code

        - Make comments consistent throughout
        - Tighten up code
        - Make local functions explicit