Fix a race in target.go.

Also, fix problems in shutdown.
Starting serving and shutdown still has to be cleaned up properly.
It's a mess.

Change-Id: I51061db12064e434066446e6fceac32741c4f84c
Clean up start-up and shut-down.

Change-Id: Idff4bbb0a15a9f879bfbb3da5b1025179cab5e2c
Fix retrieval unit tests.

Change-Id: I299b71406b59539230e5182ccc37bc8a83af60b3