Fix bugs in model save