Misc refactoring, WaitReplySafe in particular