Reorganize pkg_add slightly.
Fix upgrade.
Add missing header