Move type declaration to separate file.
Make the types module read-only externally.
Refactor into dispatch/handler model for extensibility.