adding message factory.
clearing arrays.