Fixed so that it can handle case of 0 nrecords for rotation
Merge branch 'master' into devel