NestedSet several bugfixes and refactoring