Added more error handling and debug logging