fixed some bugs and changed the function BuildModelEvolutionMatrices to be dynamic