tweaking some optimizations