Small refactor to get rid of the large switch statement.