More refactoring for #20