Better error detection and reporting.
Removed unportable "$".
Merge pull request #1 from Y-Less/master

Better error detection and reporting.