Setting up connection between parser and model and refining grammar