Refactor editor rendering code