reorganize `pkg/lib` implementation

Split the module into several (smaller) modules.
fix "redex-doc" dependencies