complete rewrite of grammar and actions