Clean up some duplicate code.