Fixed issue with indexing in SelectionLayer after undoing element selection