Correction of fragments for new protocol; some refactoring