More refactoring.
Better code structure in processNode