More refactorings, preparing for shell interactive