finished but not optimized

the classes and functions are all defined but the code is not as clean
as it could  be