Factory code clean up