fixed some bugs (some still remain regarding variables src and src2 and emap[e]