rewrite GEOMETRY part

Signed-off-by: anti-freak <antifreak2011@gmail.com>
final rewrite of GEOMETRY part

Signed-off-by: anti-freak <antifreak2011@gmail.com>