More code tidies (including a real bug).