Improve error reporting. Fix #29.