refactors some code around record-types.