kibit and eastwood.

Various changes as a result of running kibit and eastwood.
One or two bug fixes, but just neater coding.