Refactoring and performance optimisation of the model evaluation.