more refactoring, some units, and some more implementations