Fix leaks with DB.
Improve the fix to crash, the longclick an oncli problem.