Merge pull request #46 from stanislaw/master

Revised geometry: more consistent algorithm
Revised geometry #2: even more consistent algorithm