Mplot3d/crashfixes

A couple of fixes to mplot3d