Bad index (found by valgrind)

git-svn-id: svn://svn.r-forge.r-project.org/svnroot/correg@388 edb9625f-4e0d-4859-8d74-9fd3b1da38cb
some optimization

git-svn-id: svn://svn.r-forge.r-project.org/svnroot/correg@389 edb9625f-4e0d-4859-8d74-9fd3b1da38cb