Some tweaks and optimizations