Fixed AddPrimes code with full optimizations.