Cleaned up new (temp) version using partition array.
Next step - optimizations, moving to parallel version.
Added optimization, but it doesn't yet work correctly.