Updated node selection. Code cleanup.