Partially handled multiple primary key columns, plus some tidying up.