Refs #4903  Fix regression + tweaks to debug message
(thanks phpstorm for telling me the variable was unused)