Fixed some corner cases for rendering of shapes.