v3.1.x: minor refactor