Fix a bunch of problems in preparation for multi-site.