Add safeClear methods for CachedAllocator.
Fix sphere intersection logic.
Fix bug in profile sampling: overflow in segId.