Fixing bugs in model