Fix multiple Matrix code generation