bug fix and minor changes