Retab
Fix segfaults, memory leaks, etc