Release Objects before vars are deleted, fix #DllImport bugs