Ensure charset is first.
Merge pull request #1573 from arkon/master

Optimize head ordering