Varoius fixes and big refactorings
Some refactorings
Node changed to supprot new logic