Fixed memory leak in factory key.