After a mostly flat day, stocks rallied late, closing slightly higher, just enough to post record highs for the Dow and the S&P 500. Investors had to look past a pessimistic outlook from UPS, and Boeing shares fell after a 787 caught on fire in London, reviving fears of the troubles that plane had with smoldering batteries earlier this year. Other economic news was mixed. Profits at big banks Wells Fargo and JPMorgan came in better than expected, and that helped financial stocks. But a University of Michigan measure of consumer sentiment came in lower than expected for this month. Next week, reports on inflation and retail sales are due.