initially collapse import list and other minor improvs to folding
including refactoring