Part 3 - rewrite of functions

Cleaned up flatten, delIdentity. GroupNegative now works as it is intended.