Re-add the fixes from Remicks.

Change-Id: Ia8ff39878203d938624d1bbc9c072dc8900261f6