Added error messages to pkg script
Added proper return value to env debug function