Debugged version of new pkg_xxx() function
(tested against GRIF configuration)