Refactor out duplicate code from Credit.cpp.