Matlab tweaks, and pattern direction fix.