Some refactoring for sf2.1