Fixing the segmentation faults, Finishing the box algo

I suppose I can't expect crap to work if I don't return my changes :)

[no more 23:00 coding for me]