Misc optimizations