sg-schema

- completely rewritten and refactored
- added a stack of tests