Added serialization support
Added state saving and loading