speedup flat finding
typo fix
fixed finding flats in cache but not in state.