Improve model, fix bugs with ids