bug fix

fix a series of bugs