Moved duplicated code into the BoundingBox class, and pass around BoundingBox objects instead of lists of bounds.