Removed a memory leak and an uninitalized variable