Source code cleanup

Also commenting code for future beard.
Moar documentation of source
even moar documentation!