decode_header cleanup (and speedup)