Clean up error handling; be careful to not throw errors before we're connected.