Various optimizations (Thanks Nexela).
