First step towards fixing qualifier overflow

This is still a work-in-progress, since it only deals with
Python-level overflows, but it's a step forward.