Sprucing up the p2p code