fixed mem leak in the database handler