cpp: handle versioned and unversioned keys a bit better