Got mail messaging working, cleaned up messaging code