Made the database path finding more robust.