refactoring and cleaning up castmessagemanager