Buffer and bit operations optimization