time limit for pending games

and some minor refactoring.