Some changes suggested by pingou in the pull request