Various bug-fixes for playback and recording of GL streams

Bugfixes for GL trace/retrace; comments are inlined in the diffs of the original commit.