Matching (most of) Flask gloebit.py changes.