When you first reference the relationship between the observed and estimated covariance matrix Line 369, it is as $\Sigma = \Sigma(\Phi)$ where $\Sigma$ is the observed variance-covariance matrix and $\Sigma(\Phi)$ is the model-estimated version.
but a few lines later in the maximum-likelihood fitting function (Line 381) and beyond, you use $\Sigma$ (but $\hat{\Sigma}$ in the equation) as the modeled covariance matrix and $S$ as the observed covariance matrix.
I also noticed a few typos, but now see that they are addressed by #2.