Refactor registry/context. Fixes #2.