Making schema constructor returned from a function

so that it can be overridden in special cases