Fix matrix parsing