Fixed bugs in model.hpp and model.cpp