Fixed some optimizations that weren't working