a bit of refactoring and deftype work