Refactoring/cleanup of flowchart grammar