some bug fix and merge with old local