fix flawed factory
remove debug code