fix changing wave type
fix missing loops for multiple matrices