Fix bug in parseTerm.

Improve error messages.