fix a couple problems with error checking in sdk