Fixed bug in MatrixCode and general performance improvement