Adapt latest WCF changes and improve code generally