Optimized polygon cache, fixed a bug.