Refactor away some duplication