Changes by me and @hellais during code review