Retain threadend waits in savestates.

Oops, been broken since 3fb2c8f654cafe85e50586bb51d8a3c4c0e10674.
Fix some rewinding issues, better accessors.
Add rewind feature to the UI.

May not be perfect yet.
Add a warning for people with low mem devices.
Merge pull request #4420 from unknownbrackets/savestates

Enable rewind feature in UI, fix a savestate bug