clean up and optimize nth_packed_object_sha1() usage