Move a lot of stuff into a common baseclass