Improve handling of joins