gmm: factor out maximization from E-M; debug array indexing