Fixed a memory leak and removed the usage of NX_BOOL