make matrices smarter

bugfix: when copying from history, quotation mark was misplaced