Lots of small changes suggested by code reviewers