added averages support direct file saveing capabilities to cpp file