Refactoring: add config, split register into functions
Fix bugs
Rewrite table