Integrate schema into connector. Move schema to schema.lua, Refactor a lot of code