fix sporadic segfaults