Overhaul to use classes & modules. Also PEP-8 compliant.