DRY up and fix #7