Fixed error in cache prepopulation logic, some other logic errors discovered