Attempted to create save/restoreThreadState functions