HR-130 

Fixes for foreign keys