[PATCH 2/3] Refactor kernel image and initrd detection code