Various small fixes following real-life testing, and fixed bounding box calculation