Backport changes from Galileo implementation