cleaning things to avoid memory leaks and doing some other stuff