Minor changes to make error messages consistent, and possibly less crashy. Still need unit tests to trigger this code.