Support for auto swap.
Fixes #1339