Added path optimisation.

Fixes #110.