Moved the message parsing stuff to its own class