Minimize and update the grammar