Passed pervasively the impurity_function parameter

  Refactoring