Refactored several things and implemented polygon triangulation