Added further improvements to encoding performance