Added enhanced global error handling