remove config.mode, allow algo to be a function