Updated removeNode method.