Added error handling and batch processing.