Wall Street gains but caution prevails as third-quarter starts