data persistence with sqlite, memory leaks fixed