Fix matlabpool

@yuval-harpaz, I rebased, which means I pulled your recent changes and put my changes on top. You should now be able to merge this.