Enh: some small refactoring