Final solution. With comments and everything

Lied.  Now final.  Did some more function refactoring

Quick refactor