bug fixes from r-lind