adding structure factory; fix several const references therein