fixing leaks and cleaning up code