Manually merging Andreas' debug branch.