Index: src/orca/orca.py
===================================================================
--- src/orca/orca.py	(revision 3245)
+++ src/orca/orca.py	(working copy)
@@ -168,6 +168,9 @@
         # Either it's None or it's an invalid remote object.
         oldLocusOfFocus = None
 
+    orca_state.locusOfFocusHistory = orca_state.locusOfFocusHistory[:4]
+    orca_state.locusOfFocusHistory.insert(0, oldLocusOfFocus)
+
     orca_state.locusOfFocus = obj
     try:
         app = orca_state.locusOfFocus.getApplication()
@@ -1068,7 +1071,8 @@
 
     masks = []
     mask = 0
-    while mask <= (1 << pyatspi.MODIFIER_NUMLOCK):
+    # Cover all masks in 8 bits.
+    while mask <= 256:
         masks.append(mask)
         mask += 1
     pyatspi.Registry.registerKeystrokeListener(
Index: src/orca/orca_state.py
===================================================================
--- src/orca/orca_state.py	(revision 3245)
+++ src/orca/orca_state.py	(working copy)
@@ -30,6 +30,10 @@
 # easily cause circular imports.
 #
 
+# The last 5 visual focuses
+#
+locusOfFocusHistory = []
+
 # The Accessible that has visual focus.
 #
 locusOfFocus = None
