Replaced new Date() with Date.now(). Sort outgoing messages on message time and the timestamp it was received.