Fixed some memory issues with join