Fixed 500 errors in the API responses.