         didSet{
             if let tasks = selectedTasks {
                  let indexes:[Int]=tasks.map({ (task) -> Int in
-                    return self.tasks.indexOf(task)!
+                    return self.tasks.indexOf( { return $0.UID == task.UID })!
                 })
                 self.registryMetadata.stateDictionary[BartlebyDocument.kSelectedTasksIndexesKey]=indexes
                 NSNotificationCenter.defaultCenter().postNotificationName(BartlebyDocument.TASKS_SELECTED_INDEXES_CHANGED_NOTIFICATION, object: nil)

        didSet{
            if let groups = selectedGroups {
                 let indexes:[Int]=groups.map({ (group) -> Int in
                    return self.groups.indexOf(group)!
                })
                self.registryMetadata.stateDictionary[BartlebyDocument.kSelectedGroupsIndexesKey]=indexes
                NSNotificationCenter.defaultCenter().postNotificationName(BartlebyDocument.GROUPS_SELECTED_INDEXES_CHANGED_NOTIFICATION, object: nil)

        didSet{
            if let users = selectedUsers {
                 let indexes:[Int]=users.map({ (user) -> Int in
                    return self.users.indexOf( { return $0.UID == user.UID })!
                })
                self.registryMetadata.stateDictionary[BartlebyDocument.kSelectedUsersIndexesKey]=indexes
                NSNotificationCenter.defaultCenter().postNotificationName(BartlebyDocument.USERS_SELECTED_INDEXES_CHANGED_NOTIFICATION, object: nil)
