Shares now works for any general n-way join. Still need to make it more efficient.