fixed serilization with refs