Updating ScheduledTask factory to make it a little more flexible.