Precompute values for speedup.