Added reply code and made small refactoring of message sending methods