moved some functions up the inheritance tree, to get rid of some code duplication.