Added Gravy's updates to fix some bugs in rendering.