As an aside though, a small comment to document the why the invariant is necessary would be useful.