Implemented TreeDrawer and fixed some code generation bugs