Correctly handle very large input sizes
Slightly improved header
Small header read improvement