Fix bugs identified by R cmd check.