Fixed most of a pairs writing issue, more reorganization.