Fix bugs in model manager