Factor out Map, fix algorithm selection

Fixes #24