Don't set rw bit when clearing table. Added pfree().