(master) Follow up PR #2420, refactoring & clean-ups

Follow up PR #2420