bug fix and cleaning