Refactor to use generic registers