single-pagespeed-pipe: saving state

Functionality is seemingly working, but this change needs more
testing to prove it. After that some refactoring would be good.