generalized the message class registering code