Minor fixes to improve compatibility with Matlab.