Optimize various parts of the mob code