Adds automation flipping.

Implements #1289.
@Vesa will do ASAP.