Fix clearAssociates so only runs if index is present