minor error handling fixes