AVALANCHE: Fix some memory leak problems.