refactor some of the renderer code