improved error handling, still hunting for an occasional deadlock