Fix memory leaks

Plug some memory leaks.
I fixed most memory leaks reported by valgrind.

The serious one is ItemData in SQLUtils.
Most fetched data from MySQL leaks.