Initial work on a selection API

It's absolutely insane but works at least.