fixed calling of deinit()