Added more guard code for syntax errors. Further fix for #316.