FIX: Crash on deleting substations in some cases.