Mode coupling and flow energy harvesting by a flapping foil