[OnDemand] more cleanup and streamline code.