loads of optimizations, added relationship declaration and definition section