Code from vuze source code.