fixed compiler warnings and a memory leak