Refactored message status-related code