Fixed memory leak; added learning rate matrix.