add preliminary environment variables setting implementation, some cleaning