Large refactoring of invariant code. Now decorates each function with the specials required and builds the appropriate representation.