You can be mentally ill and still be criminally responsible.
James Holmes of the Aurora, Colorado theater shooting was schizophrenic. But, he was found to be criminally responsible, I believe because he showed elaborate planning.
The mental health definition of mentally ill and the criminal justice definition are different.
There's no way Vester Flanagan would have gotten off by reason of insanity.