Fix foreign keys for Applications