mam.lib: refactor and properly fix markers logging code.