This is a series of bug fixes to the new RPC code I have done since I posted the original series, which is now merged. Most of these fixes relate to handling of I/O streams. Patches 1 and 9 also impacted the original code prior to the RPC rewrite, and should be backported by people maintaining old branches