sram bugfix + savestate refactoring