all: cleanup code

Most of this code was imported from Docker and not really used here (see
issue #57).

I've reported #128, so we can add tests to env in the future, but I
believe that right now there isn't any dead code anymore.