Split pkg_object code into its own file