Right adjustmentof backwards sorted file and some refactoring