First step to extracting the functionality of this branch for compatibility with other gems.