Improve support for variants

Closes #342.