added name space module (and some memory fixes)