primitives encoding, tests, refactored schema parser