Fixed memory leak inside entitymgr