Several fixes in cache and client