Refactor various metaclasses into a common metaclass to facilitate mixins.