Improved parse error handling