Added changes to fix most of the issues with addressing a Mat object. A few changes still require Sean to fix.