Implements auto-selection.

Fixes #19.