Public back port

Back ports of changes made in the downstream project which uses this.