Add relation system, refactor entity tracking and deletion