Fixes to crash on last heading handling