Reapply James' bugfixes for get_choice and count_choices