Adding functions for working with the message queue.
Renaming functions to be have clearer names