Performance improvements for header recognition