added cleanup of K, R, T arrays in projectToNext