Fixed duplicated foreign keys and extensions