Cleaned up repetitive code
Refactored getting user avatar code in messages
Removed excess code