fix StackOverflow
remove illegal casts to SModelInternal in MPS code