Fixes ompatibility problems with Matlab R2013

Lot of fixes + compatibility problems with Matlab R2013 …