Various fixes for new primary_key_name usage