Fix 500 errors and tests.