Mass and energy flow near sunspots