refactor primary key and Model stuff

*Work in progress*