Lots of improvements and fixes to the 3d renderer.