Refactored state storage to give more options on storage