add ability to pass environment variables plus small improvements