Fix problems with joins