It might be cleaner if you could make all the updates to g.last within updateVisibility() rather than having one property updated here and the others updated later.  Not a big deal, but it would be nice to have g.last feel more atomic.