Training based on epochs, and cleaning up a bit.