Add more logging and error trapping.