Finished porting group() to XS