Eliminate some code duplication.