Matlab/2

Mostly just cleanup.  Minor bugfixes and efficiency improvements.