A little refactoring, and rewrote mailbox locality check (this version is still buggy though).