fix code struct for render and fix bugs double destructor