fix memory leaks with table deletion and cleanup