Fixed some compile warnings, a memory leak in a free function