cherry picked Mani refactor changes