Implement savestates
Refactor savestates to use macros. Shaves off about 70 LOC.