Refactory renderer code.