add factory helper and some fixes