Sorted gemvs (squashed history)

Rebased on top of today's master, this PR supersedes #92.