numerous fixes to merging and all around stability