Enh: initial refactoring