improvements to r and matlab interfaces