Changed active learning criteria, added better inversion, added outer loop