New merging with improvements from Matthias Guth.