Move some syntactic validation to earliest stage
Fix issue #215