Fix bug that's ben breaking chat

Caused by two messages with identical timestamps.

Couple of other cleanups

Change-Id: I0927636920ec3e289a8cb4b8235591d650f35cb1