[MATLAB] Added support for multiple function outputs

Some more fixes. I rebased by branch on yours so that we are in synch.