There exists a positive constant < 1 such that for any function T(n) n and for any problem L BPTIME(T(n)), there exists a deterministic algorithm running in poly(T(n)) time which decides L, except for at most a 2-(T(n) log T(n)) fraction of inputs of length n. The proof uses a novel derandomization technique based on a new type of randomness extractors, called exposure-resilient extractors. An exposure-resilient extractor is an efficient procedure that, from a random variable with imperfect randomness, produces randomness that passes all statistical tests including those that have bounded access to the random variable, with adaptive queries that can depend on the string being tested. More precisely, EXT : {0, 1}n