Lots of fixes
Implement flat area check