Improvements: Type checking, and some grammar changes