Added checks for relationship dependency loops on save. Fixed a couple of minor bugs.