Env functionality and some small changes