fix a number of error conditions