Minor code tidy and bug fix: need to set t = s after first pass and