fixed a referencing issue and an issue with relationships