Lernmatrix code - needs some cleanup.