Fix and optimize bounding box invalidation.