Improvements to rendering code