Fix problems in Andi's pull request