Add fill_matrix and match functions.