Stable version for valid dbopen(). Eliminate all memoty leaks.