Fix bugs with SJOIN and TB