Merge "Fix bugs in fallback key handling." into jb-dev