Edits and fixes based on review.

Docker-DCO-1.1-Signed-off-by: Fred Lifton <fred.lifton@docker.com> (github: fredlf)
can you use the simpler re-write of this from the other PR? this is convoluted.