more error handling fixes