code reformatting and upstream bug fix