Fixes and cleanups

Get rid of some dead code, tighten things up a bit, and fix a bug
with core::env test.