fixed a few bugs, now merging to the following line works (mostly) correctly...