fix gemsets, fix #2466
improve reseting environment before loading environment file, fix #2461