Change sort representation to class (do not review yet)

Testing...
please do not review yet... I couldn't even get the definition parsed and kompiled correctly... I need to first get all tests pass, and then come back and remove all these obsolete code one by one