Fixing some edge cases in rendering