major refactoring of rendering