Fixes mistakes and changed things around slightly.

Also did make chatid unique.