Some refactorings to prepare for inner class generator