Fix DB initialization with async DB access

Also fix the initial repository check to trigger after initialization is
complete instead of waiting