Fixed some rendering related bugs