More optimizations

This PR will grow with new commits. I'll push commits one by one to have CI run.
Why don't you continue folding in all these cases?