Fixed database opening