fixed a few optimization leaks