Fixes by Mark Rowe and Joost de Valk. Reviewed by Darin. Landed by ap.