Added error handling and reduced reliance on service calls.