fixed a memory leak and an erroneous include