Added gperm

Removed some chn.??? functions and replaced with the more flexible
gperm.