Cherrypick some commits from titanous