Refactored code. Started polygon tests.