Fixes matrix conversion errors