fix the issues that Jens identified (and a few more)