Inserting messages in proper order. Fixes #15. More testings needed