Fixed off by one error, in group and join functions.