Cleanup.
Extracted some defuns.