refactored message management