Implemented state saving!