Octree class and minor fixes to other code