Improved diacritical mapping and correct matrix environments