and a few more optimizations