Made startup faster (almost) by batching serial reads

Also corrected header-prefix algorithm. Now it's sound and complete,
before it could give wrong answers in likely-unencounterable
scenarios.