fix associations and do a few other things