Fixed bugs in model, it now compiles