Adding memory free calls

Code memory cleaning implemented