refactor Rendering, still very obfuscated