Improve error messages - fixes #878