Index: appfs-mkfs
==================================================================
--- appfs-mkfs
+++ appfs-mkfs
@@ -109,10 +109,11 @@
 					manifestfile="${appfsdir}/sha1/${RANDOM}${RANDOM}${RANDOM}${RANDOM}${RANDOM}.tmp"
 
 					(
 						cd "${version}" || exit 1
 
+						echo "#manifestmetadata,${package},${os},${cpuArch},${version}"
 						emit_manifest
 					) > "${manifestfile}"
 
 					manifestfile_hash="$(sha1 "${manifestfile}")"
 					mv "${manifestfile}" "${appfsdir}/sha1/${manifestfile_hash}"

Index: appfsd.tcl
==================================================================
--- appfsd.tcl
+++ appfsd.tcl
@@ -172,11 +172,11 @@
 		db eval {CREATE TABLE IF NOT EXISTS packages(hostname, sha1, package, version, os, cpuArch, isLatest, haveManifest);}
 		db eval {CREATE TABLE IF NOT EXISTS files(package_sha1, type, time, source, size, perms, file_sha1, file_name, file_directory);}
 
 		# Create indexes
 		db eval {CREATE INDEX IF NOT EXISTS sites_index ON sites (hostname);}
-		db eval {CREATE INDEX IF NOT EXISTS packages_index ON packages (hostname, package, version, os, cpuArch);}
+		db eval {CREATE INDEX IF NOT EXISTS packages_index ON packages (hostname, sha1, package, version, os, cpuArch);}
 		db eval {CREATE INDEX IF NOT EXISTS files_index ON files (package_sha1, file_name, file_directory);}
 	}
 
 	proc download {hostname hash {method sha1}} {
 		set url [::appfs::user::construct_url $hostname $hash $method]
@@ -305,12 +305,11 @@
 
 		return COMPLETE
 	}
 
 	proc getpkgmanifest {hostname package_sha1} {
-		set haveManifests [db eval {SELECT haveManifest FROM packages WHERE sha1 = $package_sha1 LIMIT 1;}]
-		set haveManifest [lindex $haveManifests 0]
+		set haveManifest [db onecolumn {SELECT haveManifest FROM packages WHERE sha1 = $package_sha1 LIMIT 1;}]
 
 		if {$haveManifest} {
 			return COMPLETE
 		}
 
@@ -337,10 +336,14 @@
 				set fileInfo(type) [lindex $work 0]
 				set fileInfo(time) [lindex $work 1]
 
 				set work [lrange $work 2 end]
 				switch -- $fileInfo(type) {
+					"#manifestmetadata" {
+						unset -nocomplain fileInfo
+						continue
+					}
 					"file" {
 						set fileInfo(size) [lindex $work 0]
 						set fileInfo(perms) [lindex $work 1]
 						set fileInfo(sha1) [lindex $work 2]