Did some refactoring in the geometry code.

Put polygon functions in a separate file.
Added point in polygon check.