Adding some of my latest changes.  This has grown unwieldy.  I need to rework a lot of this into much smaller functions in order to manage reflection/refraction and other things.