More optimizations and bunch of other things.