cleaning code and removing obsolete code while tracking memory leak… (WIP)