Fix crashes when deleting in editor

Array index was not clamped