Changed two group and four group algorithm and labeling according to Rafael's suggestions.