improved virtual environment handling

also fixed a setlocal issue and added a body to a new method