Refactor to make it all more generic. See CHANGELOG.