Added functions getNextSections and findPatternAfterIndex.