added fixes and features to merging, fixing bugs in mgrast