Reduced duplication in similar code.