Cleaned up error-related code based on review.