More refactoring, tweaked API