Restructure objects using vectors and sets