Message ids

Tried to fix the cid: problem + provide safer id generation
Braces on a new line please.