fix double-free
fix wrong typename
remove unused variable