Added autoswitch.

Fixes #20