Add checks
Some modifications
One more typo
Merge pull request #290 from rmcgibbo/vulnerability

[FIX] Geometry functions are vulnerable to segfaults from bad user parameters