fixes to empty the stack, fix print, children in nonleaf