Improved rendering loop