Refinancing surge helps banks amid foreclosure mess