More error handling fixes