Refactor to bring it in line with the other oregen branch