Greg/error handling fixes