Minor error handling fixes