Better heading handling (bugfix)