Fixed tree, added locale and a lot of global functions