One application_group per package. That explains the duplicate key.
Time to study on how contacts package uses groups.. and works in general