Refactored code by fixing owning and referenced relation sides, which were muddled up