Refactor field creation code.