refactorings, removed unused code, moved selected node and subnode
fields into template