[DF-4947] Refactored some code.