When setting the bounding box's top and bottom values, they were swapped, which was what caused the bug.