Refactors some repetitive render logic.