DEV: return populated data at the end of the method. (PR #13739)

And some minor refactoring.

GitHub