Restructure to accept other grammars easily