Added Geraint's fix for zeroing matrices