Fixed crash with unit switch