Fix memory leaking detected by MAOS_MEM_DEBUG. Still hasn't fixed long term memory increase issue.