Added type cast after 'set'

Required, since set can brake type consistency of the model.