Averaging problem (due to sumprocessedbytes incorrectly being reset to zero) solved, threshold lines added (below which program pauses).