Refactored segments in JSON lib  —> use Factory now

This is useful as the type of the returned class is not a stranger anymore. Easier usage in IDE :)
Also cleaned up class hierarchy, super-calls, etc.