Fixed up a few things, and compared a dataset output with the MATLAB prototype outpu