cleanups of the code (no functional changes)

This is the same changes applied to 2.9