Refactored rendering code.