Improvements to error messages to give more context

xref #49