Added initialization checking so init/deinit aren't called at the improper time.