Added a lot of changes to tree/gram. Broken at the moment.