a good chunk of the spectator code