Refactor to use init and destructor to prevent leak.