Merge support

it basically works. the tests are not yet sufficient and there are some cases not yet covered.