Improve adapter architecture

Fixes #8.