Fix many performance leaks