Multiple chains

First prototype of multiple chains code.
Have separated loc and chn functions
Added extra dimension for chains
Updated examples
merge from master
Added multiple chain example
Added gperm

Removed some chn.??? functions and replaced with the more flexible
gperm.
Merge remote-tracking branch 'origin/multiplechain'