Rewrote all message handling to use set operations