Refactoring of M-step code in full swing