Some bugfixes and minor feature additions

Fixes #241 and #282. Also extends the `-tidy` mode a bit and adds explicit  `-retainids` to the merge tool.