Updates after code review by Thomas.