Fixes bugs in model.