cleanup and adding memory free's