Fixed memory leak and compiler warning.