Refactor Env#lookup

Also remove a lot of noisy "too much configs" code that growed the
complexity of the code paths.