Did some very basic reorg of matlab code