Deadlock fixes

Includes game state cache.
This patch needs to be deeply tested.