Integrated bandiwdth estimation code and applied a few bug fixes