Fix instance badges

This fixes #619.

Nothing special here. All code is taken (and slightly adopted) from #581.