changes['phases'] contains tuples for the phase transitions, which
provides a non-trivial overhead in Python. Replace this with a Python
dictionary containing 4 bit integers. Provide accessors to centralize
changes['phases'] procsessing in one place.
On average, this improves user time for issue5691 by 1% and peak RSS by