A few more fixes

This seems to be everything needed to get things running reasonably stably on a production server...