Reduce some code duplication, add some badges.