Consolidate duplicate code.