Misc cleanups
Blatantly copy mdef as mdefp
DRY but at the expense of a private function.