reformatting mostly to tidy code. loop in run method.
again, some reformatting.