fixed infinite loop in reduce(), fixed operator+=, minor changes in main