Handle 500s from SP.
Fix error handling.