Cleaned out and optimised some graphics code.
Changes to ReferenceCountedObject to support more flexible deletion via ContainerDeletePolicy.