Updated parser with better error handling.
Improved error reporting.