added rendering to framebuffer, code cleanup