fix a bug relate to running model.write() after using model.freezeall().