Cleaned up error handling.