Do table clearing in a loop

Clearing the table in a loop instead of a map seems to stop the segfaults.