Made quality tool more flexible. Added train/test set splitting code.