Move learning code to its own library.