Better error handling fixes