Fixed some things on the learning algorithm.