some rather big refactoring before starting the SVN stream wrapper