Final pass at vectorising the loops