Fix bug with sometimes cache being not cleaned