Added checks on init and deinit