Fixed a major bug in the Java standalone version due to miscalculating the number of iterations.