Properly clean up factories