Thanks Simon and Markus for reviews.
Thanks Florian Apolloner for the report and Claude Paroz and Tim Graham for the review and help on the patch.