Make cache dir location more intelligent