Fix bounding box calculation and handling.