Global error handling added