remove config.mode, allow algo to be a function

Fixes #10, #11 

mixed space and tabs. Convert to tabs please.