further gini optimization and clean up