fix bugs in swiprologmentalstate (several casts going wrong) + fix
mentalstate factory (create new instances instead of reusing 1 instance)