Fix for crash on track removal, backported from trunk.