mam.lib: refactor code,
- Implement logging of chat markers (Fixes #152)
- Fix appending of <archived /> element (Fixes #153)