Fixed error in calculation of overlap
When both horizontal and vertical intersection was negative,
due to the multiplication the joint intersection was positive,
although it shouldn't be.