Improve syntax checking. Fixes #9