Added support for key lengths < 65535