Consolidate shared code.