Much more complete error handling.