Some refactoring and 2to3