Refactor and clean up grammars controllers