small fixes with leaks and stuff