refactored classes. not tested yet though.