Backport changes from flaviamissi