Fix segmentation fault introduced in version 3.7 with loop mode (#55)