Cleaned up IO error handling