separating the function to merge environments

separating the function to merge environments
handling of environment

final additions to make it work
bugfix

maps and genotypes should be read at once, not line-by-line