Added removal of redundant nodes