Speed up O function now that p is known.