Cherry pick old changes from develop.

Cherry picks some old changes that were never merged. This will leave the master equal to: ac89beceaa33c7007f9f9a15ffe49c84ae821f04.