tidy-up of code to use as doc samples