Sync some refactoring for better handling of message passing. Lots more to do.