Adds a better non-adjacent optimizer.

* Makes code easier to understand by splitting simple and complex scenarios.
* Adds compatibility with upcoming new property optimizer.