Added a fix for invalid linear rings