Refactor; introduce NodeFactory.