Moses bug fix

A bug fix wrapped by a half-dozen cleanup patches.