Added code to calculate maximum likelihood for learning models.
Also added tests and cleaned up code for calculating payments.