Implemented generic __set_state