Fix NPE when cache is used