fixed some bugs in the matlab driver