Fix bugs with associations