add a few optimizations