cleaning main module. Turned it into a class-level thing to make it way more (less?) complicated. Not ready for primetime yet.