Massive refactoring to support multiple renderers