fixed primary key and made some other tweaks to get a first version that basically works