Add better documentation, make messagesToSend thread-safe
Add more logging