Works for digits data. Consider weights in gini impurity. A little refactoring on code.