Taking utils code from vuze.