Improved the partitioning algorithm to n log n

Instead of n log² n, but no visible performance gain
Merge branch 'master' into Optimized_part
Multiple legalizer applications + cleanup
Added namespaces and coriolis compatibility, including cmake
Merge branch 'Optimized_part'