Implemented JoinOptimizer

Passes all tests