Fixed some issues with double matrix