Fixes issue #4967

`print` statements refactoring