Cleanup cache code into Trait and tcp transport and more cleanups