Do some optimizations