Tidy code

convert some assignments to %=