Improved error handling

I've not tested this, but I've made small commits so that when we can test it, we can bisect to find issues.

I'm aware that some of the err protection might not be necessary, but I've essentially put it anywhere I can in the box creation code.

xref scraperwiki/cobalt#46