Refactored cons cell code to involve far fewer branches.